while using getframe and the view is changing every iteration. It says cdata should be of same size. i found out that the frame size shouldn't change from a friend, but how do I determine the frame size? is there a way where i don't have to manually set the frame size even though the view is changing? In the below code the graph once saved is out of frame.
x = linspace(0,1,100);
y = linspace(0,2,200);
t = linspace(0,1,100);
z = zeros(length(x),length(y),length(t));
for count = 1:length(t)
z(:,:,count) = sin(2*pi*t(count)*x'*y/0.5)*t(count)^2;
end
[Y,X] = meshgrid(y,x);
for count = 1:length(t)
surf(X,Y,z(:,:,count));
xlabel('X(m)');
ylabel('Y(m)');
zlabel('Z(m)');
zlim([-1 1]);
colormap jet;
view([30-0.5*count 35])
frame(count) = getframe(gcf, [10 10 520 400]);
end
vidobj = VideoWriter('meshgridtrial.avi');
vidobj.Quality = 100;
vidobj.FrameRate = 20;
open(vidobj);
writeVideo(vidobj,frame);
close(vidobj);
I am getting this error:
Error using getframe (line 125)
The specified rectangle is not fully contained within the figure. MATLAB no longer supports this capability.
Error in animation_trial2 (line 33)
frames(i) = getframe(gca,[0 0 600 600]);

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 12일

0 개 추천

Since you are using getframe on the figure, so the size of cdata shouldn't matter. In your above code, you can use the following line
frame(count) = getframe(gcf);

댓글 수: 6

Lepakshi Ramkiran
Lepakshi Ramkiran 2020년 6월 12일
편집: Lepakshi Ramkiran 2020년 6월 12일
Oh yea, but what should I do when I use 3d plot?
Ameer Hamza
Ameer Hamza 2020년 6월 12일
The code in your question also has a 3D plot. What type of plot are you referring too?
Ameer Hamza
Ameer Hamza 2020년 6월 12일
Lepakshi's comment posted as answer moved here:
If i have to use getframe in appdesigner with multilple plots, what should I use?
Ameer Hamza
Ameer Hamza 2020년 6월 12일
getframe does not work with uifigure or uiaxes. I don't think there is a straightforward alternative available.
Lepakshi Ramkiran
Lepakshi Ramkiran 2020년 6월 12일
getframe worked when there was only one axis though? so you are saying we can't use getframe when there are multiple graphs?
Ameer Hamza
Ameer Hamza 2020년 6월 12일
I mean, it does not work with uiaxes() objects. axes() and uiaxes() are different objects in MATLAB. In App-designer, uiaxes() is used by default. Have you drawn axes() object in App-designer?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2020년 6월 11일

댓글:

2020년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by