surface plot figure size with getframe
2 views (last 30 days)
Show older comments
i want to make this simple animation as video, but with high resolution, so i saw that simply increasing size kinda worked. i first used fuigure('position') to get the correct number of pixels, but that always cropped a portion of the screen in the video. so i just need a way to increase image size, or increase the getframe resolution.
p.s. i just started matlab 5 days ago, and do not know much about complex functions, so plz explain in simple language or give more context.
Thanks
figure
[x,y]=meshgrid(-3:0.2:3);
for k=0:35
z=k*exp(-(x.^2+y.^2));
surf(z,'FaceAlpha',0.5);
colormap(winter)
axis([0 31 0 31 0 50])
view(45,30)
Ax.ZAxis.Visible = 'off';
Ax.ZGrid = 'off';
Ax.Color = 'none';
Ax = gca;
Ax.XAxis.Visible = 'off';
Ax.XGrid = 'off';
Ax = gca;
Ax.YAxis.Visible = 'off';
Ax.YGrid = 'off';
movieVector(k+1) = getframe;
end
myWriter = VideoWriter('curve');
myWriter.FrameRate = 50;
open(myWriter);
writeVideo(myWriter, movieVector);
close(myWriter);
end
0 Comments
Answers (1)
darova
on 16 Jun 2020
Use print to save an image with high resolution
clc,clear
opengl software
x = 0:1:10;
y = sin(x);
h = plot(x(1),y(1),'or');
line(x,y)
mkdir('test') % create folder
obj = VideoWriter('test/test.avi'); % create video file
obj.FrameRate = 5; % set speed of movie
open(obj) % open object
for i = 1:length(x)
set(h,'xdata',x(i),'ydata',y(i))% move marker
fname = sprintf('test/image%d.png',i); % file name
print(fname,'-djpeg','-r200') % save image with high resolution
I = imread(fname); % read high resolution image
writeVideo(obj,I); % write image to movie file
pause(.2)
end
close(obj);
0 Comments
See Also
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!