Plotting of for loop
显示 更早的评论
Halo
Please can anyone tell me why my for loop is not plotting for all the points on one graph but only the last value of the for loop.
a=0.171296;
b=0.856479;
c=0.25;
d=0.85285;
k1=d/a;
k2=d/c;
k3=((a^2)-(b^2)+(c^2)+(d^2))/(2*a*c);
k4=d/b;
k5=((c^2)-(d^2)-(a^2)-(b^2))/(2*a*b);
for theta2=1:1:360;
A=cosd(theta2)-k1+k3-k2*cosd(theta2);
B=-2*sind(theta2);
C=k1-k2*cosd(theta2)+k3-cosd(theta2);
D=cosd(theta2)-k1+k5+k4*cosd(theta2);
E=-2*sind(theta2);
F=k1+k4*cosd(theta2)+k5-cosd(theta2);
theta3=(2*atand((-E-(sqrt((E.^2)-(4*D.*F))^0.5)))./(2*D));
theta4=(2*atand((-B-(sqrt((B.^2)-(4*A.*C))^0.5)))./(2*A));
omega2=0.5;
omega3=((a*omega2)/b)*((sind(theta4-theta2))/(sind(theta3-theta4)));
omega4=((a*omega2)/c)*((sind(theta2-theta3))/(sind(theta4-theta3)));
plot (theta2,omega3,'b-')
grid on;
hold on;
legend('omega 3');
xlabel('theta 2');
ylabel('omega 3');
title ('Velocity of links 3 & 4');
plot (theta2,omega4,'r-')
grid on;
legend('omega 4');
xlabel('theta 2');
ylabel('omega 4');
title ('Velocity of links 3 & 4');
hold off;
end
Thank you
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!