A simple plot animation in Matlab

  • MATLAB
  • Thread starter Ahmes
  • Start date
  • #1
78
1
Hi,
Can anyone plesae help me plot [itex]y(x,t)=\sin(x)\cdot e^{-t}[/itex] on an XY axes system, and have the graph to propagate in time?

I'm really new to Matlab, and the animation demos I found were too fancy, and I couldn't figure out how to do what I want.

Thanks in advance.
 

Answers and Replies

  • #2
14
0
something like plot(sin(x)*e^(-t),([x, xstart, xend],[t, tstart, tend]))
 
  • #3
78
1
I think that plot will just draw the implicit function [itex]f(x,t)=0[/itex].
As I said I'm really new, I tried to type what you said and it gave a bunch of error messages. I tried to create vectors x and t, when it didn't work I tried symbolic variables x and t, replace e with exp(), remove some brackets... still couldn't do it.
 
  • #4
14
0
Ok try again
plot3d(y+sin(x)*e^(-t),([y, ystart, yend],[x, xstart, xend],[t, tstart, tend]));
 
Last edited:
  • #5
78
1
Are you sure about that?
First I didn't see any "plot3d"... there's just the "plot3" and "surf" - The only reference I saw between plot3 and animation is that it can draw a curve from parameterization, and animate a ball traveling on the curve (taking the parameter as time) - this is NOT what I need.
As I said, I would like to see a sine wave [itex]y=\sin(x)[/itex] whose amplitude decreases exponentially ON TIME when I push a "Play" button or something.
 
Last edited:
  • #6
78
1
YES! I think I've done it!
But it's awfully ugly :yuck: does anybody know a better way to do it?

Code:
function doit
x=-5:.2:5;
y=sin(x);
h=plot(x,y);
axis([-2*pi 2*pi -1 1])
axis square
grid off
set(h,'EraseMode','xor','MarkerSize',18)
for t=2:.1:7
    drawnow
    y=sin(x)*exp(-t);
    set(h,'YData',y)
    pause(0.05)
end
I constructed it from a demo.
 
  • #7
1
0
Hi guys

I have a similar doubt, I have an animation plot with vectors.

I have the following vector A, for example, A at time zero = [23 25 32 21 43], A in the time 1 = [32 22 33 12 42], and so on, several vectors changing their values over time.

It is possible to animate the plot in matlab?

Someone could help?

Thanks a lot guys..
 

Related Threads on A simple plot animation in Matlab

  • Last Post
Replies
1
Views
1K
Replies
1
Views
3K
  • Last Post
Replies
2
Views
4K
Replies
2
Views
952
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
6
Views
105K
  • Last Post
Replies
1
Views
5K
Replies
2
Views
1K
Replies
0
Views
3K
Top