Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 为什么;“照明电话”;要成功创建aminated GIF/电影,必须这样做吗?_Matlab_Animation_Matlab Figure_Lighting - Fatal编程技术网

Matlab 为什么;“照明电话”;要成功创建aminated GIF/电影,必须这样做吗?

Matlab 为什么;“照明电话”;要成功创建aminated GIF/电影,必须这样做吗?,matlab,animation,matlab-figure,lighting,Matlab,Animation,Matlab Figure,Lighting,我有以下Matlab代码,用于gif和avi动画的创建; Matlabimwrite用于创建gif的帧;但我发现照明命令对于成功获取动画gif至关重要 close all clear all clc; % nFrames = 50; % Preallocate movie structure. mov(1:nFrames) = struct('cdata', [],'colormap', []); % Create movie. figure('color','white'); Z = pea

我有以下Matlab代码,用于gif和avi动画的创建; Matlab
imwrite
用于创建gif的帧;但我发现
照明
命令对于成功获取动画gif至关重要

close all
clear all
clc; %
nFrames = 50;
% Preallocate movie structure.
mov(1:nFrames) = struct('cdata', [],'colormap', []);

% Create movie.
figure('color','white');
Z = peaks(150); surf(Z,Z,'edgecolor','none');
view(3);
axis vis3d tight equal off;
v = axis;
%
for k = 1:nFrames
    clf;
    surf(1.5*sin(2*pi*k/20)*Z,Z,'edgecolor','none');   
    axis(v);
    axis off
    camlight;
    lighting phong
    mov(k) = getframe;
    [Inx,cmap]=rgb2ind(mov(k).cdata,256);
    if k==1
        imwrite(Inx,cmap,'testoutx.gif','gif','DelayTime',0.25,'LoopCount',Inf)    %
    else
        imwrite(Inx,cmap,'testoutx.gif','gif','WriteMode','append','DelayTime',0.25)    %
    end
end
% Create AVI file.
  movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
当我评论“lighting phong”时,获得的gif是静态的,而不是动画的。似乎只存储了一个帧。我还尝试在每个
getframe
句子之前使用
drawnow
,但这不起作用。为什么?如果不使用
照明
,如何解决此问题

所需的gif(从上述代码中获得):

带有“lighting phong”的不需要的gif注释:


mhh即使使用phong点灯,它也能为我工作。你使用什么软件来可视化gif?可能是因为Matlab版本的不同?可能是因为我曾经在这里看到一个类似的问题,问题是用于可视化gif的web浏览器(即Chrome与Internet Explorer)。不管怎样,我使用R2013aCan你能用“lighting phong”发表你的gif文件吗?可能这是早期版本的Matlab错误;我正在使用R2010b@Benoit_11-该职位位于: