How do I make a video plot with multiple line that appears as it plots?
7 次查看(过去 30 天)
显示 更早的评论
I have the following code:
writer_obj = VideoWriter('ms_GMD_video','MPEG-4');
open(writer_obj);
% parameters
x = 1:size(GMD,2);
ms_1 = GMD(1,x);
ms_2 = GMD(2,x);
ms_3 = GMD(3,x);
ms_4 = GMD(2,x);
ms_5 = GMD(5,x);
% create plotting figure
fig1 = figure(1);
% loop over all timepoints
for i = 1:length(x)
plot(x(i),ms_1(i))
hold on
plot(x(i),ms_2(i))
hold on
plot(x(i),ms_3(i))
hold on
plot(x(i),ms_4(i))
hold on
plot(x(i),ms_5(i))
hold on
axis([1 500 min(GMD,[],'all') max(GMD,[],'all')])
title('Dissimilarity Score')
F = getframe(fig1);
writeVideo(writer_obj, F);
end
close(writer_obj)
GMD is the input, and contains five lines that I would like to plot on a graph that changes over time.
I currently have it so that we only look at the first 500 time points as an example clip, which is fine.
But when I run this, there are no lines appearing on the graph.
Any help would be appreciated, thank you.
0 个评论
采纳的回答
Antoni Garcia-Herreros
2023-5-17
Hello David,
It would be easier if you attached the the different variables (GMD, x, ms,...) as a .mat file.
The reason why the plot is not showing is because you are plotting single values with a LineStyle: '-'.
You could try something like this:
x=[0:0.1:pi];
writer_obj = VideoWriter('ms_GMD_video','MPEG-4');
open(writer_obj);
fig1=figure(1);
for i=2:length(x)
plot(x(i-1:i),sin(x(i-1:i)),'r')
hold on
plot(x(i-1:i),cos(x(i-1:i)),'b')
pause(0.1)
ylim([-1 1])
xlim([0 pi])
F = getframe(fig1);
writeVideo(writer_obj, F);
end
close(writer_obj)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!