plot the recent data with drawnow in level-2 matlab file s-function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Benutzer Name
am 17 Aug. 2018
Kommentiert: majety
am 17 Aug. 2018
Hello,
I plot a flat surface and rotate it with "drawnow" in a figure. I used to do this in a "level-2 matlab file s-function" for my Simulink simulation. It works in principal , but the figure updates the recent plot every t_out. It is like I would use the "hold on" command in a normal script. After some time its just a cylinder because Matlab saves every plot. How can I get only the recent plot in the figure, like a flat surf who rotates ?
0 Kommentare
Akzeptierte Antwort
majety
am 17 Aug. 2018
You can number the figure as figure(1) and keep plotting your circle to the same figure. Make sure you get the length of your axes right so that the animation looks good. Also remember that you can use "hold off" if you don't want a cylinder from your piled up circles.
Example:
for theta = 0:pi/50:2*pi;
x = 20 *cos(theta);
y = 20*sin(theta);
originx = 0;
originy = 0;
pause(0.01);figure(1);
plot([x,originx],[y,originy],'b','LineWidth',2);hold on;
plot(x,y,'k+','LineWidth',2);hold off;
xlim([-30,30]);ylim([-30,30]);
end
2 Kommentare
majety
am 17 Aug. 2018
try to add 'clf', so that it clears your figure before you plot over it again.
pause(0.01);figure(1);clf;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Objects 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!