matlab plot自动保存,Matlab用plot画图后怎么保存图像

Matlab用plot画图后怎么保存图像

2018-11-22

在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])附:saveassaveasSave figure or model using specified formatSyntaxsaveas(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, compressedsaveas(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.RemarksYou 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 Alsohgsave, open, printPrinting for related functions

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。

http://www.pinlue.com/style/images/nopic.gif

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值