×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Saving plots straight to PS without displaying

Saving plots straight to PS without displaying

Saving plots straight to PS without displaying

(OP)
Hi.

This may be obvious, but I've spent days searching the internet for instructions on this, but without any luck.  

I want to be able to save a plot without displaying it, so that I can leave Matlab running while it saves plots with different parameter values without opening new windows all the time.  

I can do this in Octave using the code:
  gset term postscript
  gset( "output",[\"testplot",num2str(N),".ps\""])
  plot(x,y)

This code runs through different values of N and calculates y as a function of N and saves the output as a postscript file.  

I'd like to be able to do this in Matlab to speed things up, but am having some trouble!  I'd be grateful if someone could tell me how to do it.  I'm sure someone has written code to do this, as it seems so useful.  

Thanks!  

Chris

RE: Saving plots straight to PS without displaying

Hi,
In order to save the plots you need a figure object with an axes object on it. The figure can be invisible. Do the following:
hf=figure('Visible','off');
hx=axes('Parent',hf)
for n=1:N
plot(x(:,n),y(:,n),'Parent',hx);
print(hf,'-deps',['tryplot' num2str(n)])
end

Note: By default the new plot erase the old one.

Joe Sababa

The new BSTeX - Equation viewer for Matlab7
http://www.geocities.com/bstex2001/

Joe
BSTeX- Equation viewer for Matlab
http://www.geocities.com/bstex2001

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources