24小时热门版块排行榜    

查看: 817  |  回复: 6
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

xuanyz

木虫 (小有名气)

[求助] matlab动态绘图并存储为gif和avi但图片和avi文件不动态显示 已有1人参与

请问高手
我用matlab动态绘图并存储为gif和avi但图片和avi文件不动态显示:
具体程序如下:
clear;clc; %清除所有数据

nFrames = 20;

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

% Create movie.
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
for k = 1:nFrames
   surf(sin(2*pi*k/20)*Z,Z)
   mov(k) = getframe(gcf);

if k==1
[I,map]=rgb2ind(mov(k).cdata,256);
imwrite(I,map,'out.gif','DelayTime',.1,'LoopCount',Inf)    %gif图像无限循环
else
[I,map]=rgb2ind(mov(k).cdata,256);
imwrite(I,map,'out.gif','WriteMode','append','DelayTime',0.1)    %添加到图像
end


   end
% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
还请高手指点?
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xuanyz

木虫 (小有名气)

请问这个跟操作系统有关吗?同样的这个程序,我在同样是安装有matlab2010b的win7普通版和旗舰版的两台电脑上均可以运行,但在win7普通版上运行的结果存储的文件为静态
5楼2014-11-15 12:23:12
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 7 个回答

cooooldog

铁杆木虫 (著名写手)

ส็็็

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
xuanyz: 金币+30, ★★★★★最佳答案, 最佳答案,感谢感谢 2014-11-15 12:18:45
CODE:
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;
% set(gca,'nextplot','replacechildren');
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)    %gif
    else
        imwrite(Inx,cmap,'testoutx.gif','gif','WriteMode','append','DelayTime',0.25)    %
    end
end
% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');

ส็็็็็็็็็็็็็็็็็็็็
2楼2014-11-14 20:39:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cooooldog

铁杆木虫 (著名写手)

ส็็็

你这代码如果在R2013a以后版本应该没大问题
ส็็็็็็็็็็็็็็็็็็็็
3楼2014-11-15 08:34:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xuanyz

木虫 (小有名气)

引用回帖:
2楼: Originally posted by cooooldog at 2014-11-14 20:39:15
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( ...

感谢楼主了,可否简单解释下我的程序为何有bug
4楼2014-11-15 12:19:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 303求调剂 +6 元夕元 2026-03-20 7/350 2026-03-25 12:00 by edmund7
[考研] 085600材料与化工调剂 +9 A-哆啦Z梦 2026-03-23 15/750 2026-03-25 11:18 by Ainin_
[考研] 286求调剂 +11 Faune 2026-03-21 11/550 2026-03-25 10:11 by 雾散后相遇lc
[考研] 289材料与化工(085600)B区求调剂 +4 这么名字咋样 2026-03-22 5/250 2026-03-25 08:20 by mx.yue
[考研] 材料292调剂 +8 橘颂思美人 2026-03-23 8/400 2026-03-24 16:33 by laoshidan
[考研] 材料专硕331求调剂 +4 鲜当牛 2026-03-24 4/200 2026-03-24 15:58 by JourneyLucky
[考研] 化学308分求调剂 +3 你好明天你好 2026-03-23 3/150 2026-03-23 20:11 by macy2011
[考研] 333求调剂 +6 87639 2026-03-21 10/500 2026-03-23 10:41 by Iveryant
[考研] 求调剂材料学硕080500,总分289分 5+3 @taotao 2026-03-19 21/1050 2026-03-23 10:17 by 冠c哥
[考研] 一志愿东华大学化学070300,求调剂 +7 2117205181 2026-03-21 8/400 2026-03-22 22:55 by chixmc
[考研] 298求调剂一志愿211 +3 上岸6666@ 2026-03-20 3/150 2026-03-22 15:50 by ColorlessPI
[考研] 求调剂院校信息 +6 CX 330 2026-03-21 6/300 2026-03-22 15:25 by 无懈可击111
[基金申请] 山东省面上项目限额评审 +4 石瑞0426 2026-03-19 4/200 2026-03-22 08:50 by Wei_ren
[考研] 材料求调剂 +5 @taotao 2026-03-21 5/250 2026-03-21 20:55 by lbsjt
[考研] 一志愿东华大学控制学硕320求调剂 +3 Grand777 2026-03-21 3/150 2026-03-21 19:23 by 简之-
[考研] 336求调剂 +5 rmc8866 2026-03-21 5/250 2026-03-21 17:24 by 学员8dgXkO
[考研] 一志愿重庆大学085700资源与环境总分308求调剂 +7 墨墨漠 2026-03-20 7/350 2026-03-21 16:36 by barlinike
[考研] 085601调剂 358分 +3 zzzzggh 2026-03-20 4/200 2026-03-21 10:21 by luoyongfeng
[考研] 一志愿西南交大,求调剂 +5 材化逐梦人 2026-03-18 5/250 2026-03-21 00:26 by JourneyLucky
[考研] 329求调剂 +9 想上学吖吖 2026-03-19 9/450 2026-03-20 22:01 by luoyongfeng
信息提示
请填处理意见