Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 16166|回复: 1

豆粑粑 matlab生成动画,存视频

[复制链接]

525

主题

594

帖子

2980

积分

金牌会员

Rank: 6Rank: 6

积分
2980
发表于 2020-5-8 14:15:08 | 显示全部楼层 |阅读模式
别人的问题,记录一下。

gif

gif



  1. clear all
  2. clc
  3. clf


  4. %% outline
  5. % 4 LYR anim points

  6. %% main

  7. x = -pi:0.1:2*pi;
  8. y = sin(x)+0.04*x;


  9. n_p = length(x);

  10. n_int = 6;
  11. col_mm = cool(n_int);
  12. n_end = 1;

  13. con = 1;
  14. h=figure(1);
  15. set(gca,'XLim',[-4 7],'yLim',[-1.2 1.2]);

  16. while n_end < n_p
  17.    
  18.    
  19.     ind = 1 : n_end;
  20.     plot(x,y,'color','none');
  21.     axis([-4 7 -1.2 1.2])
  22.     % plot gray point
  23.     hold on
  24.     plot(x(ind),y(ind),'o','markerfacecolor',[0.8 0.8 0.8],'markeredgecolor','none');
  25.     if n_p - n_end >  n_int
  26.         n_plot = n_int;
  27.     else
  28.         n_plot = n_p-n_end;
  29.     end
  30.     % plot color points
  31.     for i = 1: n_plot
  32.         plot(x(n_end+i),y(n_end+i),'o','markerfacecolor',col_mm(i,:),'markeredgecolor','none')
  33.         pause(0.05)
  34.         if con < 10
  35.             con_str = ['0',mat2str(con)];
  36.         else
  37.             con_str = mat2str(con);
  38.         end
  39.         fi_na = ['file_imgs/file_sin/fig_',con_str,'_',mat2str(i)];
  40.         fun_work_li_035_myfig_out(h,fi_na,3);
  41.         % mod code here and  save  your  imgs with diff name
  42.     end
  43.    
  44.     % update n_end and plot cont
  45.     n_end = n_end + n_int;
  46.     con  = con +1;
  47.     hold off
  48.     pause(0.2)
  49. end

  50. %% logs
  51. % mod  : 08-May-2020 13:22:05
复制代码


work_anim_plot_points.m.zip

1.09 KB, 下载次数: 1

m

sh_conv.sh.zip

245 Bytes, 下载次数: 1

convert

回复

使用道具 举报

525

主题

594

帖子

2980

积分

金牌会员

Rank: 6Rank: 6

积分
2980
 楼主| 发表于 2022-2-25 07:50:30 | 显示全部楼层
本帖最后由 meatball1982 于 2022-2-25 08:00 编辑

更新一下,AH的问题。

如果想把图片拼接,也可以convert
比如我有a.png b.png c.png
我想生成一个a,b在上,c在下的图
a  b
  c

我通过分别拼接实现。
因为是通过命令行实现,所以这个过程可以是脚本实现不到的i 值 ,然后,再实现转化成gif 或视频 。
具体的,看楼上。


  1. #
  2. # a + b -> lr
  3. #
  4. # lr  
  5. # +     -> ud.png
  6. # c   

  7. convert a.png b.png +append lr.png
  8. convert lr.png c.png -append ud.png

  9. convert -delay 20 'fig_*.png' sin.gif
  10. #convert -delay 20 'fig_*.png' sin.m4v



  11. # logs ###################################
  12. # mod : Fri Feb 25 07:44:10 CST 2022
复制代码





回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-3-29 08:17 , Processed in 0.113549 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表