need help with newton raphson code
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to modify the code below a)I need to set theta 2 (th2), theta 3 (th3), and theta 4(th4) as inputs;Theta 3 and theta 4 as initial guesses. b)I need to show all values of theta 3 and theta 4 for every value of theta 2 (from 0 to 360 with increments of 5) c)plot theta 2 vs transmission angle transmission angle min = 28.955 degrees and transmission angle max = 90 degrees
% code
r1 = 7; r2 =3; r3 = 8; r4 = 6;
th2 = 30; th3 = 0; th4 = 100;
d2r = pi/180; t2 = d2r*th2;t3 = d2r*th3; t4 = d2r*th4; t = [t3;t4];
f1 =1; f2 = 1; n=1;
while(abs(f1)>0.001 || abs(f2)>0.001)
f1 = r1 + r4*cos(t4)-r3*cos(t3)-r2*cos(t2);
f2 = r4*sin(t4)-r3*sin(t3)-r2*sin(t2);
G = [r3*sin(t3) -r4*sin(t4);-r3*cos(t3) r4*cos(t4)];
dt23 = inv(G)*[f1;f2];
t3 = t3 - dt23(1);
t4 = t4 - dt23(2);
t=t-dt23;
%t3 =t(1); t4 = t(2);
n = n+1;
%if(th2<= 360)
% th2=th2+5
% disp(['theta3 = ' num2str(theta3) ' theta4 = ' num2str(theta4) ' number of iter= ' num2str(n)]);
%end
if n>=20
disp(['No convergence n = ' num2str(n)])
break
end
end
theta3 = (180/pi)*t3;
theta4 = (180/pi)*t4;
disp(['theta3 = ' num2str(theta3) ' theta4 = ' num2str(theta4) ' number of iter= ' num2str(n)]);
0 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!