How to save a gif or video from matlab code?

조회 수: 2 (최근 30일)
Maitha bin gharib
Maitha bin gharib 2016년 4월 10일
답변: Image Analyst 2016년 4월 10일
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