Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: pass a figure as an argument to a function
Posted:
Mar 27, 2012 6:56 AM


"Yu " <yuzhaoshice@web.de> wrote in message <jks1go$cfr$1@newscl01ah.mathworks.com>... > I need to save a plot as vectorgraphicbased pdffile. the following function serves the purpose to avoid big margins when saving pdf files. My question is, how to call this function withs a figure, e.g. > > figure(1) > x = pi:.1:pi; > y = sin(x); > plot(x,y) > > as the first argument. > > Here the function I stole somewhere from a blogg: > > saveTightFigure(h,outfilename) > % SAVETIGHTFIGURE(H,OUTFILENAME) Saves figure H in file OUTFILENAME > [snip] Call figure with an output:
Hfigure2save = figure(1);
then call saveTightFigure with that figure handle: saveTightFigure(Hfigure2save,'varname.pdf')
HTH,



