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:
saving a figure

Subject: saving a figure

From: Snow White

Date: 14 May, 2009 11:33:01

Message: 1 of 13

Hello,

i get the following error when i try to save a fig as a *.jpg.

Error using==> print
too many input arguments

I need to use the saved image. But i cant seem to do so. It only saves it as a *.fig.

Can anyone tell me how to go abt it ?

i have also used hgsave() it saves a blank image!

Bye

Subject: saving a figure

From: Herve

Date: 14 May, 2009 11:48:01

Message: 2 of 13

What is you code ?

Subject: saving a figure

From: Clinton Cathey

Date: 14 May, 2009 11:59:02

Message: 3 of 13

In the past I've done the following:

figure(n) % where n is an integer number
set(n,'PaperOrientation','landscape')
set(n,'PaperType','usletter')

% plot commands a options

print(n,'-djpeg','FileName.jpg')

"Snow White" <gulesaman@gmail.com> wrote in message <gugvhd$t6g$1@fred.mathworks.com>...
> Hello,
>
> i get the following error when i try to save a fig as a *.jpg.
>
> Error using==> print
> too many input arguments
>
> I need to use the saved image. But i cant seem to do so. It only saves it as a *.fig.
>
> Can anyone tell me how to go abt it ?
>
> i have also used hgsave() it saves a blank image!
>
> Bye

Subject: saving a figure

From: farhad

Date: 14 May, 2009 12:18:09

Message: 4 of 13

On May 14, 2:33 pm, "Snow White" <gulesa...@gmail.com> wrote:
> Hello,
>
> i get the following error when i try to save a fig as a *.jpg.
>
> Error using==> print
> too many input arguments
>
> I need to use the saved image. But i cant seem to do so. It only saves it=
 as a *.fig.
>
> Can anyone tell me how to go abt it ?
>
> i have also used hgsave() it saves a blank image!
>
> Bye


you can use something like the following commands, after your plot or
image or 3-d plot commands:

g=get(0,'CurrentFigure');
saveas(g,'A Name','jpg')

Subject: saving a figure

From: Snow White

Date: 14 May, 2009 13:22:02

Message: 5 of 13

Clinton

i tried this :

print(1,'-djpeg','plain.jpg')

got this error:
??? Error using ==> print
Too many input arguments.
bye

"Clinton Cathey" <clintoncathey@yahoo.com> wrote in message <guh126$7a7$1@fred.mathworks.com>...
> In the past I've done the following:
>
> figure(n) % where n is an integer number
> set(n,'PaperOrientation','landscape')
> set(n,'PaperType','usletter')
>
> % plot commands a options
>
> print(n,'-djpeg','FileName.jpg')
>
> "Snow White" <gulesaman@gmail.com> wrote in message <gugvhd$t6g$1@fred.mathworks.com>...
> > Hello,
> >
> > i get the following error when i try to save a fig as a *.jpg.
> >
> > Error using==> print
> > too many input arguments
> >
> > I need to use the saved image. But i cant seem to do so. It only saves it as a *.fig.
> >
> > Can anyone tell me how to go abt it ?
> >
> > i have also used hgsave() it saves a blank image!
> >
> > Bye

Subject: saving a figure

From: Snow White

Date: 14 May, 2009 13:24:02

Message: 6 of 13

i tried wat u had suggested

g=get(0,'CurrentFigure');
saveas(g,'plain','jpg')
??? Error using ==> print
Too many input arguments.

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

farhad <farhad.24b@gmail.com> wrote in message <2beae70c-ba7f-4882-8ca0-cac8c5c793f2@z19g2000vbz.googlegroups.com>...
> On May 14, 2:33?pm, "Snow White" <gulesa...@gmail.com> wrote:
> > Hello,
> >
> > i get the following error when i try to save a fig as a *.jpg.
> >
> > Error using==> print
> > too many input arguments
> >
> > I need to use the saved image. But i cant seem to do so. It only saves it=
> as a *.fig.
> >
> > Can anyone tell me how to go abt it ?
> >
> > i have also used hgsave() it saves a blank image!
> >
> > Bye
>
>
> you can use something like the following commands, after your plot or
> image or 3-d plot commands:
>
> g=get(0,'CurrentFigure');
> saveas(g,'A Name','jpg')

Subject: saving a figure

From: Steven Lord

Date: 14 May, 2009 13:32:50

Message: 7 of 13


"Snow White" <gulesaman@gmail.com> wrote in message
news:guh61i$3v3$1@fred.mathworks.com...
>i tried wat u had suggested
>
> g=get(0,'CurrentFigure');
> saveas(g,'plain','jpg')
> ??? Error using ==> print
> Too many input arguments.
>
> Error in ==> saveas at 159
> print( h, name, ['-d' dev{i}] )

Are you certain you're using the correct PRINT function? Type "which -all
print" without the quotes at the prompt. You should see one in the
toolbox/matlab/graphics directory (and perhaps two in the toolbox/mbc
directory, if you have that toolbox installed.) If you see any other
instances of PRINT listed, you should rename them, remove them, move the
directories containing them lower on the MATLAB path, or remove those
directories from the path (the latter two you can do with PATHTOOL.)

--
Steve Lord
slord@mathworks.com

Subject: saving a figure

From: Snow White

Date: 14 May, 2009 13:38:01

Message: 8 of 13

i get this:
MATLAB\print.m
print is a Java method % Shadowed com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas method
print is a Java method % Shadowed com.mathworks.hg.peer.AxisCanvas method
print is a Java method % Shadowed java.awt.Canvas method
print is a Java method % Shadowed java.awt.Component method
print is a built-in method % Shadowed javahandle.com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas method
print is a Java method % Shadowed com.mathworks.hg.peer.FigureFrameProxy$FigureFrame method
print is a Java method % Shadowed com.mathworks.mwswing.desk.DTSingleClientFrame method
print is a Java method % Shadowed com.mathworks.mwswing.desk.DTFrame method
print is a Java method % Shadowed com.mathworks.mwswing.MJFrame method
print is a Java method % Shadowed javax.swing.JFrame method
print is a Java method % Shadowed java.awt.Frame method
print is a Java method % Shadowed java.awt.Window method
print is a Java method % Shadowed java.awt.Container method
C:\MATLAB\R2008a\toolbox\matlab\graphics\print.m % Shadowed

"Steven Lord" <slord@mathworks.com> wrote in message <guh6hv$7fl$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:guh61i$3v3$1@fred.mathworks.com...
> >i tried wat u had suggested
> >
> > g=get(0,'CurrentFigure');
> > saveas(g,'plain','jpg')
> > ??? Error using ==> print
> > Too many input arguments.
> >
> > Error in ==> saveas at 159
> > print( h, name, ['-d' dev{i}] )
>
> Are you certain you're using the correct PRINT function? Type "which -all
> print" without the quotes at the prompt. You should see one in the
> toolbox/matlab/graphics directory (and perhaps two in the toolbox/mbc
> directory, if you have that toolbox installed.) If you see any other
> instances of PRINT listed, you should rename them, remove them, move the
> directories containing them lower on the MATLAB path, or remove those
> directories from the path (the latter two you can do with PATHTOOL.)
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: saving a figure

From: Steven Lord

Date: 14 May, 2009 14:15:40

Message: 9 of 13


"Snow White" <gulesaman@gmail.com> wrote in message
news:guh6rp$r2l$1@fred.mathworks.com...
>i get this:
> MATLAB\print.m
> print is a Java method % Shadowed
> com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas method
> print is a Java method % Shadowed
> com.mathworks.hg.peer.AxisCanvas method
> print is a Java method % Shadowed
> java.awt.Canvas method
> print is a Java method % Shadowed
> java.awt.Component method
> print is a built-in method % Shadowed
> javahandle.com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas
> method
> print is a Java method % Shadowed
> com.mathworks.hg.peer.FigureFrameProxy$FigureFrame method
> print is a Java method % Shadowed
> com.mathworks.mwswing.desk.DTSingleClientFrame method
> print is a Java method % Shadowed
> com.mathworks.mwswing.desk.DTFrame method
> print is a Java method % Shadowed
> com.mathworks.mwswing.MJFrame method
> print is a Java method % Shadowed
> javax.swing.JFrame method
> print is a Java method % Shadowed
> java.awt.Frame method
> print is a Java method % Shadowed
> java.awt.Window method
> print is a Java method % Shadowed
> java.awt.Container method
> C:\MATLAB\R2008a\toolbox\matlab\graphics\print.m % Shadowed

This is the one that you should be using, but it's not the one that you are
using.

> MATLAB\print.m

Did you create this function named print.m? If so, it's shadowing the
print.m that ships with MATLAB, and so when you try to print it's being
called instead. Rename or remove this one.

*snip*

--
Steve Lord
slord@mathworks.com

Subject: saving a figure

From: Image Analyst

Date: 14 May, 2009 14:40:03

Message: 10 of 13

"Snow White"
Try this from the file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/23629

Subject: saving a figure

From: Snow White

Date: 14 May, 2009 14:41:04

Message: 11 of 13

I havent created any such function... i checked now and none of them ahas been created by me

"Steven Lord" <slord@mathworks.com> wrote in message <guh929$ofu$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:guh6rp$r2l$1@fred.mathworks.com...
> >i get this:
> > MATLAB\print.m
> > print is a Java method % Shadowed
> > com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas method
> > print is a Java method % Shadowed
> > com.mathworks.hg.peer.AxisCanvas method
> > print is a Java method % Shadowed
> > java.awt.Canvas method
> > print is a Java method % Shadowed
> > java.awt.Component method
> > print is a built-in method % Shadowed
> > javahandle.com.mathworks.hg.peer.FigureAxisComponentProxy$_AxisCanvas
> > method
> > print is a Java method % Shadowed
> > com.mathworks.hg.peer.FigureFrameProxy$FigureFrame method
> > print is a Java method % Shadowed
> > com.mathworks.mwswing.desk.DTSingleClientFrame method
> > print is a Java method % Shadowed
> > com.mathworks.mwswing.desk.DTFrame method
> > print is a Java method % Shadowed
> > com.mathworks.mwswing.MJFrame method
> > print is a Java method % Shadowed
> > javax.swing.JFrame method
> > print is a Java method % Shadowed
> > java.awt.Frame method
> > print is a Java method % Shadowed
> > java.awt.Window method
> > print is a Java method % Shadowed
> > java.awt.Container method
> > C:\MATLAB\R2008a\toolbox\matlab\graphics\print.m % Shadowed
>
> This is the one that you should be using, but it's not the one that you are
> using.
>
> > MATLAB\print.m
>
> Did you create this function named print.m? If so, it's shadowing the
> print.m that ships with MATLAB, and so when you try to print it's being
> called instead. Rename or remove this one.
>
> *snip*
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: saving a figure

From: Steven Lord

Date: 14 May, 2009 17:43:36

Message: 12 of 13


"Snow White" <gulesaman@gmail.com> wrote in message
news:guhai0$4r3$1@fred.mathworks.com...
>I havent created any such function... i checked now and none of them ahas
>been created by me

It doesn't really matter _who_ created the function that's shadowing the one
that ships with MATLAB, just that it _is_ shadowing the one that ships with
MATLAB. As I said before, rename or remove this one:

>> > MATLAB\print.m

--
Steve Lord
slord@mathworks.com

Subject: saving a figure

From: Snow White

Date: 20 May, 2009 12:57:01

Message: 13 of 13

I have resolved that.

The problem that i get is the matrix that i save as a *.jpg has values that vary from 0-1 but when i save the resulting images as a figure it contains the values while *.jpg it converts them to 0-255 range. How can this be resolved or a the figure used as a normal jpeg?

bye

"Steven Lord" <slord@mathworks.com> wrote in message <guhl85$nrg$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:guhai0$4r3$1@fred.mathworks.com...
> >I havent created any such function... i checked now and none of them ahas
> >been created by me
>
> It doesn't really matter _who_ created the function that's shadowing the one
> that ships with MATLAB, just that it _is_ shadowing the one that ships with
> MATLAB. As I said before, rename or remove this one:
>
> >> > MATLAB\print.m
>
> --
> Steve Lord
> slord@mathworks.com
>

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