MATLAB: Problem about the scipt

loopmatrix

clear all
l = 25
E = 200*10^9
I = 350*10^-6
w = 6*10^3
x = input('enter length of the beam')
if (x>=0)&(x<= l/2),
y = -w*x/384*E*I *(16*x^3-24*l*x^2+9*l^3);
elseif
(x>=l/2)& (x<= l);
y = -w*x/384*E*I*(8*x^3-24*l*x^2+(17*l^2)*x-l^3)
end
Why I can not get the value of y? How to get it?

Best Answer

y DOES get assigned. Verify by stepping through your code. If you don't know how to do that, see this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ Also, the line that says
(x>=l/2)& (x<= l);
should probably have a % in front of it because it doesn't do anything and appears like it should be a comment.