24小时热门版块排行榜    

查看: 802  |  回复: 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的回帖

cooooldog

铁杆木虫 (著名写手)

ส็็็

你这代码如果在R2013a以后版本应该没大问题
ส็็็็็็็็็็็็็็็็็็็็
3楼2014-11-15 08:34:14
已阅   回复此楼   关注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的回帖

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的回帖

xuanyz

木虫 (小有名气)

请问这个跟操作系统有关吗?同样的这个程序,我在同样是安装有matlab2010b的win7普通版和旗舰版的两台电脑上均可以运行,但在win7普通版上运行的结果存储的文件为静态
5楼2014-11-15 12:23:12
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 一志愿郑大材料学硕298分,求调剂 +5 wsl111 2026-03-01 5/250 2026-03-01 23:45 by 暮雨星晴
[考研] 材料学硕318求调剂 +5 February_Feb 2026-03-01 5/250 2026-03-01 23:31 by L135790
[考研] 292求调剂 +6 yhk_819 2026-02-28 6/300 2026-03-01 23:23 by 向上的胖东
[考研] 0854复试调剂 276 +3 wmm9 2026-03-01 3/150 2026-03-01 23:13 by 热情沙漠
[考研] 0856调剂 +5 刘梦微 2026-02-28 5/250 2026-03-01 22:30 by wang_dand
[考研] 材料类求调剂 +10 wana_kiko 2026-02-28 12/600 2026-03-01 22:10 by 海嵙Y
[考研] 299求调剂 +3 Y墨明棋妙Y 2026-02-28 5/250 2026-03-01 21:01 by tangxiaotian
[考研] 306分材料调剂 +4 chuanzhu川烛 2026-03-01 5/250 2026-03-01 19:48 by 无际的草原
[考研] 298求调剂 +6 axyz3 2026-02-28 6/300 2026-03-01 19:00 by 18137688336
[考研] 一志愿中南大学理学化学 +4 15779376950 2026-03-01 5/250 2026-03-01 19:00 by Fff-1
[考研] 291分工科求调剂 +9 science饿饿 2026-03-01 10/500 2026-03-01 18:55 by 18137688336
[考研] 化工专硕348,一志愿985求调剂 +5 弗格个 2026-02-28 8/400 2026-03-01 17:25 by sunny81
[考研] 290求调剂 +9 材料专硕调剂; 2026-02-28 11/550 2026-03-01 17:21 by sunny81
[考研] 295复试调剂 +3 简木ChuFront 2026-03-01 3/150 2026-03-01 14:27 by zzxw520th
[考研] 302材料工程求调剂 +4 Doleres 2026-03-01 5/250 2026-03-01 11:52 by liqiongjy
[考研] 寻找调剂 +4 LYidhsjabdj 2026-02-28 4/200 2026-03-01 10:56 by sunny81
[论文投稿] 求助coordination chemistry reviews 的写作模板 10+3 ljplijiapeng 2026-02-27 4/200 2026-03-01 09:07 by babero
[论文投稿] Optics letters投稿被拒求助 30+3 luckyry 2026-02-26 4/200 2026-03-01 09:06 by babero
[考研] 307求调剂 +4 73372112 2026-02-28 6/300 2026-03-01 00:04 by ll247
[硕博家园] 【博士招生】太原理工大学2026化工博士 +4 N1ce_try 2026-02-24 8/400 2026-02-26 08:40 by N1ce_try
信息提示
请填处理意见