Plot overlapped on each other
37 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yanjika O
el 8 de Jun. de 2020
Comentada: Yanjika O
el 8 de Jun. de 2020
Hello,
I have this code for making animated plots in a loop and writing it into a video. However, when my second loop runs, the second plot appears to be plotted on top of the previous first plot.
filename='audioShockRecall.xlsx';
sheetname_kinovea=regexprep(filename,'.xlsx','');
conditioning=3;
col='B':'D';
x=1:1:509;
y1=10;
curve=animatedline('LineWidth',2,'Color','b');
set(gca, 'ylim',[0 500], 'xlim',[0 510],'OuterPosition',[0 0 1 1]);
grid on;
ylabel('\fontsize{14}Speed,px/s');
xlabel('\fontsize{14}Time,frame');
for i=1:conditioning
speed=xlsread(filename,sheetname_kinovea,strcat(col(i),':',col(i)));
figure(i);
for j=1:length(speed)
addpoints(curve,x(j),speed(j));
drawnow
F(j)=getframe(gcf);
title(strcat('Trajectory:Conditioning',(num2str(i))),'FontSize',16);
end
video=VideoWriter(strcat('Conditioning',num2str(i),'.mp4'),'MPEG-4');
video.FrameRate=30;
open(video);
writeVideo(video,F);
close(video);
end
How can I plot them all in separate figure? Or is there something wrong I wrote.
0 comentarios
Respuesta aceptada
Image Analyst
el 8 de Jun. de 2020
Yes, that's what you told it to do. You first plotted an animated line in figure 1, then in your loop you said
figure(i);
so it reused figure #1 on the first iteration of your for loop. You should have just said
figure
and let it decide for itself what the number is.
And you forgot to attach 'audioShockRecall.xlsx' so we could run it.
Más respuestas (1)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!