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

How to do a dynamic graph in matlab

  1. Jun 5, 2013 #1
    Hi guys, so i've never used matlab before, and i need to make a plot that changes constantly.
    Let's say that i have Sin(x) from 0 to 3pi
    Then i need it to change to a Cos(x) from 0 to 3pi
    then to a Tan(x).

    I could do it in other languaje like Php or c, but in matlab i have no idea. I think it can be made with a for cycle nested inside of another for cycle.
     
  2. jcsd
  3. Jun 5, 2013 #2
    Nevermind, i got it. What i really wanted was a changing sin plot. I'm gonna leave it here in case anyone needs it.
    Code (Text):

    f = @(x,t) 1.5*sin(10*x-5*(t/10));
    linkdata on
    hold on;
    for t=1:50
        xi = -3*pi:pi/1000:pi;
        plot(f(xi,t));
        pause(.1);
    clf('reset')
    end
     
     
    Last edited: Jun 6, 2013
  4. Jun 6, 2013 #3

    kreil

    User Avatar
    Gold Member

    Very cool!
     
  5. Jun 6, 2013 #4
    Thanks (:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to do a dynamic graph in matlab
Loading...