Iterating through alternating for loops
Mostrar comentarios más antiguos
I am trying to run a code where I want to plot strides side by side and alternate between plotting one left and one right stride. To do this I am running 2 for loops where one is nested in another. What I was hoping to achieve is where one loop is run and then the other one and this pattern alternates until all steps are plotted (left,right,left,right...). What is currently happening is that one loop run and then all of the second for loop runs without switching back to the previous one. I would like some help in understanding what I am doing wrong here.
For context I have put a portion of my code below:
t = tiledlayout(1,2);
nexttile;
hold on;
for(ii=1:size(right_strides.ltrl,2))
plot(right_strides.ltrl(:,ii),right_strides.frwd(:,ii),'Color','b')
x = right_strides.ltrl(end,ii);
y = right_strides.frwd(end,ii);
h = animatedline;
for i =1:length(x)
addpoints(h,x(i),y(i));
drawnow;
end;
nexttile;
hold on;
for(ii=1:size(left_strides.ltrl,2))
plot(left_strides.ltrl(:,ii),left_strides.frwd(:,ii),'Color','r')
xL = left_strides.ltrl(end,ii);
yL = left_strides.frwd(end,ii);
hL = animatedline;
for i =1:length(x)
addpoints(hL,xL(i),yL(i));
drawnow;
end
end;
end;
Any help is appreciated!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Animation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
