A simple plot animation in Matlab

In summary, someone could help you plot a function y=sin(x) on an XY axes system and have the graph to propagate in time.
  • #1
Ahmes
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.
 
Physics news on Phys.org
  • #2
something like plot(sin(x)*e^(-t),([x, xstart, xend],[t, tstart, tend]))
 
  • #3
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
Ok try again
plot3d(y+sin(x)*e^(-t),([y, ystart, yend],[x, xstart, xend],[t, tstart, tend]));
 
Last edited:
  • #5
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
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
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..
 

1. What is a simple plot animation in Matlab?

A simple plot animation in Matlab is a type of visualization tool that allows users to create a series of plots that are displayed in sequence, creating the illusion of movement or change over time. It is commonly used for visualizing data, simulations, and other types of numerical analysis.

2. How do I create a simple plot animation in Matlab?

To create a simple plot animation in Matlab, you will need to use the "plot" function to create your initial plot, and then use the "pause" and "drawnow" functions to add a delay between each frame of the animation. You can also use the "for" loop to automate the process and create a sequence of plots that are displayed in order.

3. Can I customize the appearance of my plot animation in Matlab?

Yes, you can customize the appearance of your plot animation in Matlab by using various formatting options such as changing the line style, color, and marker type. You can also add titles, labels, and legends to your plot to make it more informative and visually appealing.

4. How can I save my plot animation in Matlab as a video or GIF?

To save your plot animation in Matlab as a video or GIF, you will need to use the "VideoWriter" or "imwrite" functions, respectively. These functions allow you to save your animation as a file that can be easily shared or embedded in presentations or reports.

5. Are there any resources available to help me learn more about plot animation in Matlab?

Yes, there are many online tutorials, forums, and documentation available to help you learn more about plot animation in Matlab. You can also refer to the official Matlab documentation or take online courses to improve your skills and understanding of this topic.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
553
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
986
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top