MATLAB: Help plotting basic x vs y

plot

Hello, I am trying to plot x and y from x = 0 to x=L. Right now it goes haywire and plots a bunch of vertical lines which is not correct. Can someone tell me how to fix this? Thank you.
%constants
w0 =2.5 %kN/cm
L = 600 %cm
I = 30000 %cm^4
E = 50000; %kN/cm^2
%equation
y = @(x) w0./(120*E*I*L)*(-5*x^4+6*L^2*x^2-L^4);
x =linspace(0,L,100);
fplot(x,y)
ylabel('Displacement [cm]')
xlabel('Location [cm]')
title('Max Deflection at x = 531.2241cm')

Best Answer

x =linspace(0,L,100);
y =w0./(120*E*I*L)*(-5*x.^4+6*L^2*x.^2-L^4);
plot(x,y);
Related Question