How do I make a video plot with multiple line that appears as it plots?
6 ビュー (過去 30 日間)
古いコメントを表示
David Haydock
2023 年 5 月 17 日
回答済み: Antoni Garcia-Herreros
2023 年 5 月 17 日
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!