how could i animate a series as an animation ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
HADIMARGO
am 13 Dez. 2018
Bearbeitet: Adam Danz
am 28 Jan. 2020
a function like :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/198986/image.jpeg)
just with loop
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 13 Dez. 2018
Bearbeitet: Adam Danz
am 28 Jan. 2020
Here's a demo below. First create the data, set up the figure, then loop through each coordinate to plot the next line segment (or dot); use drawnow to update the plot on each iteration.
Run this demo to watch the sin wave form.
% Create your data
x = 0:.1:4*pi;
y = sin(x);
% Create figure
figure
ah = axes;
% Set axis limits so they aren't continually adjusted
ylim([-1,1])
xlim([0, 4*pi])
hold(ah, 'on') %Hold the axis!
% loop through each point / line segment
for i = 2:numel(x)
plot(x(i-1:i), y(i-1:i), '-b')
drawnow %Update the plot!
end
Update: Here are better demos and more options I added 2 years later
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!