This is a matlab based coding question. Please add comment statements for each s
ID: 3812177 • Letter: T
Question
This is a matlab based coding question. Please add comment statements for each section of code. Thanks!!
Also, if you could show verification calculations of the equations that would be great!!!
outer_radius.txt:
7
8.5
6
4.5
7.5
inner_radius.txt:
5
8
4
3.5
5.5
mass.txt:
10
3
15
20
7.5
Explanation / Answer
A=importdata('inner_radius.txt');
B=importdata('outer_radius.txt');
C=importdata('mass.txt');
%getrow count
inrows=size(A,1);
outrows=size(B,1);
massrows=size(C,1);
%convert to vectorusing row count here
in_vctr=reshape(A',1,inrows);
out_vctr=reshape(B',1,inrows);
mass_vctr=reshape(C',1,massrows);
%formula I=2m/5((r2^5-r1^5)/((r2^3-r1^3))
%use loop variable and store the values into vector
%using vector math for the above formula and storing into final vector
final_vec=((2*mass_vctr)/5)*((((out_vctr.^5)-(in_vctr.^5)))/((out_vctr.^3)-(in_vctr.^3)));
%displaying the list after inputs paired
disp(final_vec);
%using if else statement we use for loop for vectors individual elemnet and check if any value >high
high=final_vec(1);
index=1;
for i=1:length(final_vec)
if(final_vec(i)>high)
high=final_vec(i);%store high value in high and ake the index
index=i;
end
end
%get the highest value inertia's corresponding values using the index
out_radius=out_vctr(index);
inner_radius=in_vctr(index);
mass_val=mass_vctr(index);
fprintf('The highest moment of Inertia is %d and corresponding outer radius ,inner radius and mass are: %d,%d,%d ',high,out_radius,inner_radius,mass_val)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.