Why doesn't this MATLAB loop plot y values correctly?

  • Context: MATLAB 
  • Thread starter Thread starter j-lee00
  • Start date Start date
  • Tags Tags
    Loop Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 7K views
j-lee00
Messages
93
Reaction score
0
for x = 1:15

if x < 5
y = 2*x - 5;

elseif 5 < x <10
y = 4*x;

elseif 10< x <15
y = x*x;

end;

end;

plot(x,y)

Why doesn't this work?
 
Physics news on Phys.org