From sources-request at octave dot org Fri Jun 3 23:34:22 2005 Subject: matlab saveas function From: "Andrew Fitting" To: sources at octave dot org Date: Fri, 3 Jun 2005 18:48:35 -0500 This is a multi-part message in MIME format. --------------050209050703020903070409 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=iso-8859-1; format=flowed oops, i'm really sorry, the previous email i sent had the wrong version of the file. this should be correct. it should replicate the saveas functionality except for being able to actually use the figure handle. andrew --------------050209050703020903070409 Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename=saveas.m Content-Type: text/plain; name=saveas.m ## -*- texinfo -*- ## at deftypefn {Function File} {} saveas (@var{h}, @var{filename}, @var{fmt}) ## Save the plot window whose handle is at var{h} to @var{filename}. ## at var{fmt} can be any ImageMagick format ## at end deftypefn ## Author: andrew fitting function status = saveas (h,filename,varargin) ## make sure filename only has the file name and the suffix is in fmt if( nargin < 3) point = rindex(filename,'.') if(point > 0) fmt = substr(filename,point+1,length(filename)-point) filename = substr(filename,1,point-1) else fmt = "EPS" end elseif( nargin > 2) fmt = varargin{1} end ## generate an eps file from the last plot statement (notice this ignores h) gset(['output "',filename,'.',fmt,'"']) gset terminal postscript color replot gset output gset terminal x11 ## this section requires ImageMagick if(fmt != 'EPS' && fmt != 'eps') system(['mogrify -rotate "90" -format ',fmt,' ',filename,'.',fmt]) end ## end ImageMagick Section status = 0; endfunction --------------050209050703020903070409--