在matlab中自动保存plot图像的程序

Step 1. 先使所画的图最大化,即占满整个屏幕

scrsz = get(0,'ScreenSize');

figure1=figure('Position',[0 30 scrsz(3) scrsz(4)-95]);或者(下面这种情况会把windows系统下面的任务栏也保存到图片中,不太好)scrsz = get(0,'ScreenSize');

figure1=figure('Position',[0 0 scrsz(3) scrsz(4)-66]);

% Step 2. 生成数据并画图

x=rand(100,1);

plot(x);

saveas(gcf,'filename','bmp');

saveas(gcf,'filename','emf');

saveas(gcf,'filename','jpg');

% Step 3. 清理现场

clear all; clc; close all;下面的代码可以创建一个大小为整个屏幕的四分之一,位置在屏幕在左上角的一个figure对像,使用root对象的ScreenSize属性来取得屏幕的尺寸,ScreenSize是由四个元素组成的数据:[left,bottom,width,height])。

scrsz = get(0,'ScreenSize');

figure2=figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])

附:saveas

saveasSave figure or model using specified format

Syntax

saveas(h,'filename.ext')

saveas(h,'filename','format')Descriptionsaveas(h,'filename.ext') saves the figure or model with the handle h to the file filename.ext.The format of the file is determined by the extension, ext. Allowable values for ext arelisted in this table.

ext ValueFormataiAdobe Illustrator `88bmpWindows bitmapemfEnhanced metafileepsEPS Level1figMATLAB figure (invalid for Simulink models)jpgJPEG image (invalid for Simulink models)mMATLAB M-file (invalid for Simulink models)pbmPortable bitmappcxPaintbrush 24-bitpgmPortableGraymappngPortable Network GraphicsppmPortable PixmaptifTIFF image, compressed

saveas(h,'filename','format') saves the figure or model with the handle h to the file calledfilename using the specified format. The filename can have an extension, but the extension isnot used to define the file format. If no extension is specified, the standard extensioncorresponding to the specified format is automatically appended to the filename.

Allowable values for format are the extensions in the table above and the device typessupported by print. The print device types include the formats listed in the table ofextensions above as well as additional file formats. Use an extension from the table above orfrom the list of device types supported by print. When using the print device type to specifyformat for saveas, do not use the prefixed -d.

Remarks

You can use open to open files saved using saveas with an m or fig extension. Other formatsare not supported by open. The Save As dialog box you access from the figure window's Filemenu uses saveas, limiting the file extensions to m and fig. The Export dialog box you accessfrom the figure window's File menu uses saveas with the format argument.

ExamplesExample 1: Specify File ExtensionSave the current figure that you annotated using the Plot Editor to a file named pred_preyusing the MATLAB fig format. This allows you to open the file pred_prey.fig at a later timeand continue editing it with the Plot Editor.

saveas(gcf,'pred_prey.fig')Example 2: Specify File Format but No ExtensionSave the current figure, using Adobe Illustrator format, to the file logo. Use the aiextension from the above table to specify the format. The file created is logo.ai.

saveas(gcf,'logo', 'ai')This is the same as using the Adobe Illustrator format from the print devices table, which is-dill; use doc print or help print to see the table for print device types. The file createdis logo.ai. MATLAB automatically appends the ai extension for an Illustrator format filebecause no extension was specified.

saveas(gcf,'logo', 'ill')Example 3: Specify File Format and ExtensionSave the current figure to the file star.eps using the Level 2 Color PostScript format. If youuse doc print or help print, you can see from the table for print device types that the devicetype for this format is -dpsc2. The file created is star.eps.

saveas(gcf,'star.eps', 'psc2')In another example, save the current model to the file trans.tiff using the TIFF format withno compression. From the table for print device types, you can see that the device type forthis format is -dtiffn. The file created is trans.tiff.

saveas(gcf,'trans.tiff', 'tiffn')See Also

hgsave, open, print

Printing for related functions

matlab 画图直接存储_Matlab用plot画图后怎么保存图像相关推荐

  1. matlab 画图直接存储_Matlab Figure图形保存

    1.使用Matlab绘制出数据的各种图形需要保存的时候,不少同学是直接用屏幕截图的办法来做的,但这样出来的图并不清晰,不便于后续应用和处理,并且往往不符合发表论文的要求,很多论文是要求用 .eps 格 ...

  2. matlab plot画图指定线型和颜色

    matlab plot画图指定线型和颜色 plot(x,y1,'.b'); %b代表蓝色,.代表点; plot(x,y2,'-g'); %g代表绿色,-代表线

  3. MATLAB plot画图后横轴去除空白

    MATLAB plot画图后横轴去除空白 MATLAB plot原来画图都是填充满的,今天不知道怎么了,横轴留有一部分空白,看起来十分不美观,可以修改一下上下限使其美观一些. 方法 x轴上下限设定 x ...

  4. MATLAB 利用plot 画图,加标题,保存图片

    MATLAB plot 画图,加标题,保存图片 plot(x,y,'.'); %画图 title("标题"); %设置标题 xlabel("X轴"); %设置X ...

  5. Matlab plot画图 坐标字体、字号、范围、间隔等的设置

    Matlab plot画图 坐标字体.字号.范围.间隔等的设置 MATLAB 坐标的数字.范围.间隔调整 matlab绘图的时候只用plot函数出来的图不一定符合自己最想要的格式, 经常要对坐标的数字 ...

  6. 【Matlab】Matlab导入多个.mat文件并画图的过程详解

    Matlab导入多个.mat文件并画图的过程详解 0. 实验背景 1. 导入.mat文件存储 1.1 导入.mat文件及作图最简单的方式: 1.2 导入.mat文件及作图的脚本代码 2. plot画图 ...

  7. matlab绘图 excel,『在matlab上如何导入excel表格然后画图』excle表格如何使用绘图笔...

    excel怎样在绘制图形中加入文字 1.在excel表制图形中加入文以添加文字,首先绘制图形,图形绘制好图形,并选择"编辑文字",输入文字即可. 1.1插入图形, 1.2,选择所需 ...

  8. python怎么画参数函数图像_详解pandas.DataFrame.plot() 画图函数

    首先看官网的DataFrame.plot( )函数 DataFrame.plot(x=None, y=None, kind='line', ax=None, subplots=False, share ...

  9. maltab利用plot画图后更改线条颜色

    在matlab中,利用plot画图默认好像只有八种颜色,分别为:b--蓝色,r--红色,m--品红,k--黑色,g--绿色,c--青色,y--黄色,w--白色.有时候我们画的线条比较多,这几种颜色可能 ...

  10. matlab导入表格画图,matlab从excel表格导入数据画图-在matlab上如何导入excel表格然后画图...

    如何将excel表格中大量数据导入matlab中并作图 1.matlab,点击主页下面的数据导入,你可以导入excel数据,这里导自己的huitushuju文件. 2.单击"打开" ...

最新文章

  1. dockefile nginx php,dockerfile自动部署nginx+php7
  2. iOS 不同机型屏幕适配
  3. Java环境变量配置详细步骤
  4. poj 1338 Ugly Numbers(丑数模拟)
  5. 使用final类的作用是什么?
  6. lightgbm 数据不平衡_数据不平衡问题
  7. java 监控对象是什么_多线程-Java中的对象监视器是什么意思? 为什么要使用这个词?...
  8. 研磨设计模式学习笔记3--适配器模式Adapter
  9. 利用iPhone下载其他地区的App
  10. openEuler 高校开发者大赛报名启动!广阔天地,码出不凡
  11. 华为OJ-整形数组合并
  12. 2021年危险化学品经营单位主要负责人考试报名及危险化学品经营单位主要负责人新版试题
  13. 让0球平局怎么算_古迪逊公园默郡德比,平局德比丨第30轮
  14. linux nfs 测试 读写,部署NFS与测试NFS
  15. 使用matplotlib修改字体之Times New Roman
  16. charles抓包https证书下载
  17. 【JVM · 字节码】指令集 解析说明
  18. android4.4 获取符合默认短信应用要求的短信应用包名
  19. 大数据时代隐私泄露呈高发趋势 如何有效预防成关键
  20. 学习游戏建模的方式有哪些?次世代游戏建模学习路线以及要掌握的3D软件分别是?

热门文章

  1. 阿里云域名注册+网站备案
  2. 【懒人必备神器】教你用Python做一个自动抽奖程序啦~
  3. 前后落差大用什么词语_形容两个人反差特别大的成语-有明显的反差 用什么词形容-形容前后态度反差巨大的词...
  4. 动态规划:HDU1248-钱币兑换问题
  5. 宇宙也能测量,破解未解之谜的三维地图出炉
  6. Playground 教程之SceneKit绘制个Torus圆环面
  7. Dynamic Programming 什么意思
  8. 类型多样的电子数码免抠元素素材,速来收藏
  9. 服务器软硬件安装和配置,Windows Server 2016-系统安装软硬件要求
  10. 使用pdfbox把PDF转换成图片