How do I create an animated errorbar?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 20 Mar 2018
Réponse apportée : MathWorks Support Team
le 17 Avr 2018
Is there a way to create an animated errorbar similar to an animated line?
Réponse acceptée
MathWorks Support Team
le 20 Mar 2018
You cannot make an animated line directly from an errorbar, but you can draw the error bar in steps to make it appear animated:
x = 1:10:100;
y = [20 30 45 40 60 65 80 75 95 90];
figure
ax = gca;
axis([0 100 10 110]);
for k = 1:numel(x)
% all values until the current time step
xVals = x(1:k);
yVals = y(1:k);
% error bars will be 5 units below and 10 units above each point
negativeDelta = 5*ones(1,numel(yVals));
positiveDelta = 10*ones(1,numel(yVals));
% draw the error bar
errorbar(ax,x(1:k),y(1:k),negativeDelta,positiveDelta);
% maintain axis limits since errorbar function will dynamically change
% the axis limits
axis([0 100 10 110]);
% pause between time steps to simulate animation
pause(0.5)
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!