how to put animatedline in subplots
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello!
I am trying to organise 3 subplots- 2 animatedline plots in separate charts and a 2D (2 variable) graph. All graphs will be based on the same time frame and move simultaneously. Subplot 3 works ok, but the animated plots don't work as they do in their own. Is this possible? Can anyone help with my code?
Many thanks,
josh
for i=1:length(ver)
sub1=subplot(3,1,1);
axis([0,550,-0.00003,0.00003]);
h = animatedline('Color','r');
addpoints(h, i, ver(i));
sub2=subplot(3,1,2);
axis([0,550,-0.00003,0.00003]);
v = animatedline('Color','b');
addpoints(v, i, hor(i));
sub3=subplot(3,1,3);
axis(gca,'equal');
axis([-.00003, 0.00003, -0.00003, 0.00003]);
grid on;
O=[0 0];
P = [ver(i),hor(i)];
addpoints(h,ver(i),hor(i))
pend = line([O(1) P(1)],[O(2) P(2)]);
ball = viscircles(P,0.0000004);
pend.Color = 'black';
pend.LineWidth = 3;
drawnow
if i<length(ver)
delete(pend);
delete(ball);
end
end
0 commentaires
Réponses (1)
Walter Roberson
le 24 Déc 2018
N = 550;
ver = randn(1, N)/100000; hor = randn(1, N)/100000;
sub1 = subplot(3,1,1);
cla(sub1);
axis(sub1, [0, N, -0.00003, 0.00003]);
h = animatedline(sub1, 'Color', 'r');
sub2 = subplot(3,1,2);
cla(sub2);
axis(sub2, [0, N, -0.00003, 0.00003]);
v = animatedline(sub2, 'Color', 'b');
sub3 = subplot(3,1,3);
cla(sub3);
axis(sub3, 'equal');
axis(sub3, [-.00003, 0.00003, -0.00003, 0.00003]);
grid(sub3, 'on');
pend = line(sub3, nan, nan, 'color', 'black', 'LineWidth', 3);
O=[0 0];
for i=1:length(ver)
addpoints(h, i, ver(i));
addpoints(v, i, hor(i));
P = [ver(i), hor(i)];
addpoints(h, ver(i), hor(i));
set(pend, 'XData', [O(1) P(1)], 'YData', [O(2) P(2)]);
ball = viscircles(sub3, P, 0.0000004);
drawnow
if i<length(ver)
delete(ball);
end
end
couldn't see much of the circle, though.
0 commentaires
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!