Problem creating video mp4 from animation.

6 ビュー (過去 30 日間)
jakaria babar
jakaria babar 2020 年 2 月 14 日
コメント済み: jakaria babar 2020 年 2 月 14 日
What's wrong with this code? Can you help me please?
%% Creating Video mp4 from Animation of a graph a point P(x,y) which is variable connected to three fixed point A(6,9),B(20,38),C(49,25).
clc
clear
close all
M=5000;
x=6:1:49; % x domain
y=9:1:38; % y domain
for i=1:length(x)
for j=1:length(y)
clf
L=sqrt((x(i)-6)^2+(y(j)-9)^2)+sqrt((x(i)-20)^2+(y(j)-38)^2)+sqrt((x(i)-49)^2+(y(j)-25)^2);
if L<M
M=L;
a=x(i);
b=y(j);
p = [6 20 49]; % x coordinates of three fixed points A, B, and C.
q = [9 38 25]; % y coordinates of three fixed points A, B, and C.
hold on;
grid on
title('Steiner minimal tree')
for n = 1:length(p)
plot([p(n) a],[q(n) b],'color',[0 0 1]);
myChar = char(64+n);
text(p(n)+1,q(n),myChar);
end
plot(p,q,'o','markerfacecolor','k','markeredgecolor','none', ...
'markersize',4);
plot(a,b,'o','markerfacecolor','r','markeredgecolor','none', ...
'markersize',8);
text(a+0.5,b+0.75,'P');
drawnow;
pause = .01;
F(i,j)= getframe(gcf);
end
end
end
mywriter = videowriter('Steiner minimal tree','MPEG-4');
mywriter.framerate = 60;
open(mywriter);
writevideo(mywriter,F);
close(mywriter);
Whwn I run this file command window shows
Cannot find an exact (case-sensitive) match for 'videowriter'
The closest match is: VideoWriter in F:\Matlab Alx\toolbox\matlab\audiovideo\@VideoWriter\VideoWriter.m
Error in animate_figure (line 37)
mywriter = videowriter('Steiner minimal tree','MPEG-4');

採用された回答

Bhaskar R
Bhaskar R 2020 年 2 月 14 日
VideoWriter % correct one you have give videowriter(not case sensitive)
  3 件のコメント
Bhaskar R
Bhaskar R 2020 年 2 月 14 日
This works for you
%% Creating Video mp4 from Animation of a graph a point P(x,y) which is variable connected to three fixed point A(6,9),B(20,38),C(49,25).
clc
clear
close all
M=5000;
x=6:1:49; % x domain
y=9:1:38; % y domain
mywriter = VideoWriter('Steiner minimal tree','MPEG-4');
% mywriter.framerate = 60;
mywriter.FrameRate = 60;
open(mywriter);
for i=1:length(x)
for j=1:length(y)
clf
L=sqrt((x(i)-6)^2+(y(j)-9)^2)+sqrt((x(i)-20)^2+(y(j)-38)^2)+sqrt((x(i)-49)^2+(y(j)-25)^2);
if L<M
M=L;
a=x(i);
b=y(j);
p = [6 20 49]; % x coordinates of three fixed points A, B, and C.
q = [9 38 25]; % y coordinates of three fixed points A, B, and C.
hold on;
grid on
title('Steiner minimal tree')
for n = 1:length(p)
plot([p(n) a],[q(n) b],'color',[0 0 1]);
myChar = char(64+n);
text(p(n)+1,q(n),myChar);
end
plot(p,q,'o','markerfacecolor','k','markeredgecolor','none', ...
'markersize',4);
plot(a,b,'o','markerfacecolor','r','markeredgecolor','none', ...
'markersize',8);
text(a+0.5,b+0.75,'P');
drawnow;
pause = .01;
% F(i,j)= getframe(gcf);
writeVideo(mywriter,getframe(gcf));
end
end
end
% mywriter = videowriter('Steiner minimal tree','MPEG-4');
% writevideo(mywriter,F);
close(mywriter);
jakaria babar
jakaria babar 2020 年 2 月 14 日
Thank you so much. The code has worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by