How to save a gif or video from matlab code?

1 次查看(过去 30 天)
So i have a specific code that generates a moving plot, however, i want to save that as a video so i can easily access it instead of having to run the code every time. The code is very easy, it's as follows:
%%%%%%%%%%%%%%%%%%
for i=1:50
t(i)=0.1*i;
P=[0 0 20]';
s=[ 0 0 1];
R1 = [cos(i*0.0174532) 0 sin(i*0.0174532)];
R2 = [0 1 0];
R3 = [-sin(i*0.0174532) 0 cos(i*0.0174532)];
Rx = [1 0 0; 0 cos(i*0.0174532) -sin(i*0.0174532); 0 sin(i*0.0174532) cos(i*0.0174532)];
R = [R1; R2; R3];
B1 = [ 15 15 0 ]'; %sph
B2= [-15 15 0]'; %rev
B3 = [-15 -15 0]'; %rev
B4 = [15 -15 0]'; %sph
A1 = [5,14,0]'; %sph
A2 = [-30,30,0]'; %rev
A3 = [-30,-30,0]'; %rev
A4 = [5,-14,0]'; %sph
b1 = P +(R*B1); %sph
b2 = P +(R*B2); %rev
b3 = P +(R*B3); %rev
b4 = P +(R*B4); %sph
% A random rotation
b11 = [b1';
b2';
b3';
b4'];
% Base
A11 = [5 14 0 ;
-30 30 0 ;
-30 -30 0 ;
5 -14 0] ;
verts = [A11 ; b11] ;
faces = [1 2 3 4; 2 6 7 3; 4 3 7 8; 1 5 8 4; 1 2 6 5; 5 6 7 8];
patch('Vertices', verts, 'Faces', faces, 'FaceColor', 'w');
pause(0.003)
axis([-35 35 -40 50 -5 60])
end
%%%%%%%%%%%%%%%%%%%%%%%

回答(1 个)

Image Analyst
Image Analyst 2016-4-10

类别

Help CenterFile Exchange 中查找有关 Robotics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by