How to do a dynamic graph in matlab

  • Context: MATLAB 
  • Thread starter Thread starter juanitotruan77
  • Start date Start date
  • Tags Tags
    Dynamic Graph Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 8K views
juanitotruan77
Messages
44
Reaction score
0
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.
 
Physics news on Phys.org
Nevermind, i got it. What i really wanted was a changing sin plot. I'm going to leave it here in case anyone needs it.
Code:
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:
kreil said:
Very cool!

Thanks (: