clear one plot in multiple (hold) figure
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
islam dib
il 14 Dic 2020
Risposto: Ameer Hamza
il 14 Dic 2020
Hello,
I want to follow a point by plotting him every time. I want just plot the point not all previous points.
I've tried to use this code, but it gives all points.
x = 1:0.01:25;
y = sin(x);
n = numel(x);
%figure;
for i = 1:n
h=plot(x(1:i),y(1:i),'+r');
xlim([0 25]);
ylim([-1.1 1.1]);
%refreshdata(figure,'base')
pause(0.001);
% drawnow;
delete(h)
end
How can I fix the problem ?
0 Commenti
Risposta accettata
KALYAN ACHARJYA
il 14 Dic 2020
Modificato: KALYAN ACHARJYA
il 14 Dic 2020
x = 1:0.01:25;
y = sin(x);
n = numel(x);
%figure;
for i = 1:n
h=plot(x(i),y(i),'+r');
xlim([0 25]);
ylim([-1.1 1.1]);
pause(0.001);
delete(h)
end
0 Commenti
Più risposte (1)
Ameer Hamza
il 14 Dic 2020
Another computationally efficient approach is to create a single line object and update its XData and YData properties
x = 1:0.01:25;
y = sin(x);
n = numel(x);
%figure;
h = plot(nan, '+r');
xlim([0 25]);
ylim([-1.1 1.1]);
hold on
for i = 1:n
h.XData = x(i);
h.YData = y(i);
%refreshdata(figure,'base')
pause(0.001);
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!