Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i already have a code , u can analyze my code and give me some other direction .

ID: 661130 • Letter: I

Question

i already have a code , u can analyze my code and give me some other direction .

function Untitled2
clc
clear all
% Ti=To
Ti=input('coefficien Ti:');
Ai=input('coefficien Ai:');
Bi=input('coefficien Bi:');

%for each shaft enter Li, ODi, IDi, Gi
Li=input('coefficient Li:');
ODi=input('coefficient ODi:');
IDi=input('coefficient IDi:');
Gi=input('coefficient Gi:');
%Now we can compute the" Ji "and Shearing stress" tau" , and angle of
%twist aot
if IDi>0
Ji=(pi/32)*(ODi^4-IDi^4);
else if IDi == 0
Ji=1/2*pi*ODi^4;
end
end
%we found the polar moment of inertia ,now we can find the shearing stress
tau = Ti*(ODi/2)/Ji;
%angle of twist "aot"

aot=Ti*Li/Gi*Ji;
aot1=aot*180/pi;
%angle of rotation "aor" at end Ai.compute rotation at the "A and of each shaft start with angle=aor and update to 1and add aot"
aor=aot*Ai/(Bi + tau);
aor1=aor*180/pi;

fprintf('Shaft No Max.Stress(ksi) Twist Angle(degrees) ')
fprintf(' %15.3f %15.3f ', tau, aot1);

fprintf('Angle throug A1 rotates %f = ' ,aor1);

Explanation / Answer

Your code should work fine. If you want an alternate method than you can use switch case statement and after that code will work as per your convinience and requirement.