Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:45:42+00:00 2026-05-23T18:45:42+00:00

I am a Mac (10.6.8) user. I have written MATLAB code for plotting calculation

  • 0

I am a Mac (10.6.8) user. I have written MATLAB code for plotting calculation results and then saving the plots as pdfs. I use “saveas” (see example below).

I get this error:

??? Error using ==> print at 325
Problem converting PostScript. System returned error: -1.Failed to convert to output format; Ghostscript status: -100.**** Unable to open the initial device, quitting.

Error in ==> saveas at 155
        print( h, name, ['-d' dev{i}] )

Error in ==> Results_processor at 1219
saveas(gcf,saveFigTo1, 'pdf')

Here is the relevant piece of code:

calculationResultsPath    = '/Me/Projects/ThisProject';
calculationResultsDirectory          = strcat( calculationResultsPath,'MATLABProcessedResults' );
mkdir( calculationResultsDirectory );

% ...Code for importing results to be plotted from external files (works fine)...

% ...Code for plotting (works fine)... I get the figures I want.

% The problem is:
saveFigTo1    = strcat(resultsDirectory,'/majorsMgO.pdf') 
saveas(gcf,saveFigTo1, 'pdf') 
hold off
pause
clf;

Some further information… This worked fine last week when I first wrote it! Since then, I think I updated to Mac OS 10.6.8 from 10.6.7, but nothing else has changed in my code or in the version of Matlab I use (R2009a) (unless I have a very bad memory!).

Also, I came across some older suggestions on similar questions to use “print.” I tried using:

print(gcf,’filename’). I did get a pdf, but it would not open in any pdf viewing programme. I assume (but don’t know for sure) that this could be related to the fact that I use a Mac. I have noticed that there are a few things (especially related to external file manipulation) that don’t run on Mac.

If anyone could help, I would be very grateful.


Update:
I found a GhostScript for Mac and installed it as Chris suggested. Unfortunately, that didn’t work. I read on a forum that many Mac users are having problems with MATLAB plots at present, possibly related to java. There was an operating system update (to OS X 10.6.8) last week and that is when the problems began. My code worked before then.

I still have not found a solution to this and I don’t think the MATLAB people have either, so if anyone has suggestions about how to save plots WITHOUT using saveas, I would love to hear them. The “print” command does not work for me either–it produces PDFs that I can’t open.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:45:43+00:00Added an answer on May 23, 2026 at 6:45 pm

    One recommendation I can make is to use a different format that OS X understands and simply convert the result to pdf with a system call

    See if the following works:

    % Load a test image
    im = imread('cameraman.tif');
    
    imshow(im); % display the image
    
    saveas(gcf,'test.tif','tif');
    
    % convert to pdf using a syscall to cupsfilter
    !cupsfilter test.tif > test.pdf 2> /dev/null
    
    % open the file with your default pdf viewer 
    !open test.pdf
    

    If the above is not working, yet another approach is to get the bitmap from the figure window and write it using imwrite. Note, this method doesn’t benefit from the nice font scaling features of the saveas and print. This approach assumes the im variable above still exists.

    imagesc(im); colormap gray;
    
    % Set the border color to white
    set(h,'Color',[1 1 1]);
    
    % Get the image in the figure
    frame = getframe(gcf);
    imout = frame.cdata;
    
    % on OS X, the stretch window image 
    % appears in the bottom right corner 
    % of the image.  Remove it. 
    imout = imout(10:end-9,10:end-9,:);
    
    % Write the image out to a lossless tif
    imwrite(imout,'test.tif','tif','Compression','none')
    

    You could then convert the tifs to pdf files as above. The quality of the figure will depend on the figure size. In most cases, I wouldn’t use this second approach as saveas handles the fonts nicely. Using getframe is meant only as a workaround to the true problem with saveas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am an avid TextExpander for Mac user. I use it to expand code
I have written a software which I would like to bind to mac. Is
I have written a program in c, that do some calculations then creates a
I have RTF text which I am showing to the user on Mac. Now
I have a Cocoa app for Mac OS X written in Xcode 4. The
I am a Mac/Ubuntu user. I have folders such as AWK, awk, awk_tip and
I'm a Mac user and I've decided to learn Emacs. I've read that to
I'm a Mac user, so I know that for Mac OS X, I'd like
(I'm a mac user) I'm new at this whole programing thing. its been explained
I am a long-time Mac user looking to gain a decent understanding of Windows.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.