Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Error using print in an m-file

Subject: Error using print in an m-file

From: Chris Rae

Date: 12 Oct, 2010 22:04:04

Message: 1 of 1

I'm trying to use the print command to create a pdf of the figure window.

I've used an old Matlab easter egg as the figure just for an example, my eventual code will loop over several figures but the principal is the same.
If I type the following code into the editor and execute it in in cell mode, it works, if I select the text in the editor and hit F9, it works, if I copy the code into the command window and hit enter it works, but if I save it as an m-file and run it (which is how it will need to be implemented) I get an error.

Code:
image % Creates the easter egg in figure 1 %
print -f1 -dpdf % Where 1 is the handle of the figure to be printed, assuming no other figures are open %

Error:
Error using ==> figure
Single input must be an existing figure handle or a scalar integer from 1 to
2147483646

Any help would be appreciated.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us