Clear Filters
Clear Filters

why doesn't any data show up on my figure?

1 view (last 30 days)
i'm trying to make a basic 4-bar linkage position tracking graph, but the graph shows up blank when i run it. any help?
% Lengths of Linkages
a=269.755;
b=182.014;
c=345.91;
d=154.91;
e=110.524;
% Initial Angles
theta0=0.544892;
theta20=2.504722;
theta30=0.612262;
alpha=0.559028959;
% J-Values & Geometry Calculations
j1=d/a;
j2=d/c;
j3=(a^2 - b^2 + c^2 + d^2)/(2*a*c);
j4=d/b;
j5=(c^2 - d^2 - a^2 - b^2)/(2*a*b);
q=atan((a*sin(theta20))/(d-(a*cos(theta20))));
f=sqrt(a^2 +d^2 - 2*a*d*cos(theta20));
p=atan((sqrt(4*b^2*f^2 - (b^2 + f^2 - c^2)^2))/(b^2 +f^2 - c^2));
% Coupler Position
xc=a*cos(theta20) + e*cos(p-q+alpha);
yc=a*sin(theta20) + e*sin(p-q+alpha);
z=-xc*cos(theta0) - yc*sin(theta0);
% Range Of Input Angles
theta2=[(theta20-(degtorad(45))):pi/180:(theta20+(degtorad(45)))];
% Loop
for i=theta2;
D=j5-j1+((1+j4)*cos(i));
E=-2*sin(i);
F=j5+j1-((1-j4)*cos(i));
theta3=2*atan((-E-sqrt(E^2 - 4*D*F))/(2*D));
camber=radtodeg(theta3-theta30);
q1=atan((a*sin(i))/(d-(a*cos(i))));
f1=sqrt(a^2 +d^2 - 2*a*d*cos(i));
p1=atan((sqrt(4*b^2*f1^2 - (b^2 + f1^2 - c^2)^2))/(b^2 +f1^2 - c^2));
xc1=a*cos(i) + e*cos(p-q+alpha);
yc1=a*sin(i) + e*sin(p-q+alpha);
z1=-xc1*cos(theta0) - yc1*sin(theta0);
height=z1-z;
end
% Plot Results
figure
grid on
xlabel('camber angle(degrees)','FontSize',18)
ylabel('Wheel Travel(mm)','FontSize',18)
title('Camber Angle With Wheel Travel','FontSize',20)
plot(camber,height)
i'm pretty new to matlab so any help would be much appreciated. Cheers Michael

Accepted Answer

Walter Roberson
Walter Roberson on 24 Nov 2012
You overwrite camber and height each time through the "for i" loop.
camber = []; height = [];
for i = theta2
...
camber(end+1) = radtodeg(....)
[...]
height(end+1) = z1-z;
end

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!