24小时热门版块排行榜    

查看: 801  |  回复: 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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 求调剂 +4 yunziaaaaa 2026-03-01 4/200 2026-03-01 23:45 by L135790
[考研] 0856材料与化工,270求调剂 +6 YXCT 2026-03-01 6/300 2026-03-01 23:21 by 向上的胖东
[考研] 275求调剂 +3 明远求学 2026-03-01 3/150 2026-03-01 22:29 by 刘兵
[考研] 274求调剂 +3 cgyzqwn 2026-03-01 6/300 2026-03-01 21:24 by cgyzqwn
[考研] 298求调剂 +6 axyz3 2026-02-28 6/300 2026-03-01 19:00 by 18137688336
[考研] 0856材料求调剂 +11 hyf hyf hyf 2026-02-28 12/600 2026-03-01 18:57 by 18137688336
[考研] 0857调剂 +3 一ll半 2026-02-28 3/150 2026-03-01 18:32 by 热情沙漠
[考研] 材料学调剂 +9 提神豆沙包 2026-02-28 11/550 2026-03-01 18:15 by ms629
[考博] 26申博 +4 想申博! 2026-02-26 6/300 2026-03-01 17:32 by 想申博!
[考研] 290求调剂 +9 材料专硕调剂; 2026-02-28 11/550 2026-03-01 17:21 by sunny81
[考研] 281求调剂 +4 2026计算机_诚心 2026-03-01 7/350 2026-03-01 17:20 by 2026计算机_诚心
[考研] 285求调剂 +8 满头大汗的学生 2026-02-28 8/400 2026-03-01 16:47 by caszguilin
[基金申请] 刚录用,没有期刊号,但是在线可看的论文可以放为代表作吗 10+3 arang1 2026-03-01 3/150 2026-03-01 16:43 by babero
[考研] 课题组接收材料类调剂研究生 +3 gaoxiaoniuma 2026-02-28 4/200 2026-03-01 14:30 by jjj三跨
[考研] 295复试调剂 +3 简木ChuFront 2026-03-01 3/150 2026-03-01 14:27 by zzxw520th
[考研] 284求调剂 +6 天下熯 2026-02-28 6/300 2026-03-01 14:19 by Ducount.Y
[考研] 307求调剂 +4 73372112 2026-02-28 6/300 2026-03-01 00:04 by ll247
[考研] 276求调剂 +3 路lyh123 2026-02-28 4/200 2026-02-28 19:45 by 路lyh123
[高分子] 求环氧树脂研发1名 +3 孙xc 2026-02-25 11/550 2026-02-28 16:57 by ichall
[硕博家园] 【博士招生】太原理工大学2026化工博士 +4 N1ce_try 2026-02-24 8/400 2026-02-26 08:40 by N1ce_try
信息提示
请填处理意见