Hi guys,
New to using Matlab, and my assignment requires to plot 2 graphs, here's the code:
%Program that calculates the ratio of the suspension stiffness in the
%deflected position to that in the static position over a range of
%positions of O (50degrees - 70 degrees to horizontal).
%Kspr = spring constant = 108.2N/mm
%Kstat = suspension constant in static position
%Kdef = suspension constant in deflected position
dw = -607.5; %vertical wheel motion in the static position
Kspr = 108.2;
dW = -620; %vertical wheel motion in the deflected position
x = linspace(50,70,200); %range of angles in degrees
Rx = -cosd(x); %horizontal component of position vector O to E
Ry = -sind(x); %vertical component of position vector O to E
ds = ((-88.63*Rx)+(-250.44*Ry)); %spring compression motion in static position, ds = (velocity of E).R
dS = ((-234.7*Rx)+(-204.16*Ry)); %spring compression motion in deflected position
Kstat = (((Kspr)*(ds).^2)/(dw)^2);
Kdef = (((Kspr)*(dS).^2)/(dW)^2);
ratio = (Kdef/Kstat);
%Graph plot for Kdef and Kstat for the range of angles 50 - 70 degrees
plot(x,Kdef,x,Kstat)
legend('Kdef','Kstat')
xlabel('Angle in degrees')
ylabel('Suspension stiffness/ N/mm')
title('Graph of Kdef and Kstat at a range of angles')
%Graph plot for the ratio Kdef/Kstat for range of angles 50-70 degrees
plot(x,ratio)
xlabel('Angle in degrees')
ylabel('Suspension constant ratio (Kdef/Kstat)')
title('Graph of Suspension constant ratio at a range of angles')
Ok, so the problem is this, the first graph is fine (looks fine at least), however the second graph for plotting the ratio just gives me a straight line? I subbed in a few values manually to work out the ratio (Kdef/Kstat) and it definitely isn't a constant so why is the plot giving me a straight line?
Thanks in advance!!