Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab loop help

  1. Jul 20, 2008 #1
    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 doesnt this work?
     
  2. jcsd
  3. Jul 20, 2008 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    no equal signs, you are leaving out 5, 10 and 15 right off the bat.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Matlab loop help
  1. Matlab loop help (Replies: 1)

  2. For loop in matlab (Replies: 3)

Loading...