24小时热门版块排行榜    

查看: 810  |  回复: 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

木虫 (小有名气)

再次感谢了,不过你改过的程序确实可以运行,多谢了
7楼2014-11-16 15:50:09
已阅   回复此楼   关注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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 请教下大家 2026年国家基金申请是双盲审吗? +3 lishucheng1 2026-03-22 5/250 2026-03-24 08:22 by gltch
[考研] 335分 | 材料与化工专硕 | GPA 4.07 | 有科研经历 +4 cccchenso 2026-03-23 4/200 2026-03-23 23:00 by 徐ckkk
[考研] 0703化学求调剂 +4 奶油草莓. 2026-03-22 5/250 2026-03-23 19:37 by pswait
[考研] 333求调剂 +3 ALULU4408 2026-03-23 3/150 2026-03-23 19:04 by macy2011
[考研] 328求调剂 +4 LHHL66 2026-03-23 4/200 2026-03-23 14:55 by lbsjt
[考研] 招08考数学 +6 laoshidan 2026-03-20 14/700 2026-03-23 14:37 by 15614359529
[考研] 306求调剂 +9 chuanzhu川烛 2026-03-18 9/450 2026-03-23 13:17 by luoyongfeng
[考研] 寻找调剂 +4 倔强芒? 2026-03-21 4/200 2026-03-22 16:14 by 木托莫露露
[考研] 化学调剂 +5 yzysaa 2026-03-21 5/250 2026-03-21 22:12 by peike
[考研] 材料与化工(0856)304求B区调剂 +3 邱gl 2026-03-20 7/350 2026-03-21 19:05 by 15709483992
[考研] 一志愿深大,0703化学,总分302,求调剂 +4 七月-七七 2026-03-21 4/200 2026-03-21 18:20 by 学员8dgXkO
[基金申请] 学校已经提交到NSFC,还能修改吗? 40+4 babangida 2026-03-19 9/450 2026-03-21 16:12 by babangida
[考研] 0805材料320求调剂 +3 深海物语 2026-03-20 3/150 2026-03-21 15:46 by 无际的草原
[考研] 083200学硕321分一志愿暨南大学求调剂 +3 innocenceF 2026-03-17 3/150 2026-03-21 02:35 by JourneyLucky
[考研] 一志愿中海洋材料工程专硕330分求调剂 +8 小材化本科 2026-03-18 8/400 2026-03-20 23:16 by JourneyLucky
[考研] 304求调剂 +7 司空. 2026-03-18 7/350 2026-03-20 23:08 by JourneyLucky
[考研] 288求调剂 +16 于海海海海 2026-03-19 16/800 2026-03-20 22:28 by JourneyLucky
[考研] 086500 325 求调剂 +3 领带小熊 2026-03-19 3/150 2026-03-20 18:38 by 尽舜尧1
[考研] 【同济软件】软件(085405)考研求调剂 +3 2026eternal 2026-03-18 3/150 2026-03-18 19:09 by 搏击518
[硕博家园] 湖北工业大学 生命科学与健康学院-课题组招收2026级食品/生物方向硕士 +3 1喜春8 2026-03-17 5/250 2026-03-17 17:18 by ber川cool子
信息提示
请填处理意见