【问题标题】:How to convert existing .fig files to .jpg on matlab [duplicate]如何在matlab上将现有的.fig文件转换为.jpg [重复]
【发布时间】:2016-06-05 03:27:14
【问题描述】:

我有一个目录中的.fig 文件列表。

如何编写一个简单的matlab函数,自动将所有.fig文件转换为.jpg文件?

【问题讨论】:

  • 阅读手册!有打开图的功能,也有保存图的功能。
  • 我强烈建议将 matlab 图形保存到 .png 而不是 .jpgjpg 压缩会导致您的身材出现很多锯齿,而 .png 文件不会出现这种情况。

标签: matlab jpeg


【解决方案1】:

Matlab 无花果只是您必须加载到 Matlab 中以进行解释和转换的矩阵,因此您可以尝试以下操作:

fig=openfig(FileName,'new','invisible');
saveas(fig,OutputFileName.jpg,'jpg')
close(fig);

“不可见”选项不会在绘图中打开无花果,因此可以节省内存和时间。

【讨论】:

    【解决方案2】:

    GameOfThrows 的回答有助于将单个 .fig 文件保存到 .jpg

    要遍历所有 .fig 文件,这对我有用:

    //obtain the files with .fig extension
    files = dir('*.fig');
    
    //loop through the .fig files
    for i=1:length(files)
    
       //obtain the filename of the .fig file
       filename = files(i).name;
    
       //open the figure without plotting it
       fig = openfig(filename, 'new', 'invisible');
    
       //save the figure as a jpg
       saveas(fig, 'example.jpg');
    
       //close the figure so that the next could be opened without some java problem
       close;
    
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-10
      • 2012-10-10
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      • 2019-09-22
      • 2020-06-25
      相关资源
      最近更新 更多