From: us on
"Helen " <helenfromsun(a)gmail.com> wrote in message <hkk6v2$dvr$1(a)fred.mathworks.com>...
> Hi Rune, and thanks for your reply.
>
> I tried your suggestion but it didn't work. I am running 2009b which, to be honest, sucks badly compared to earlier versions. Here's a quote from the documentation:
>
> "This example combines the previous two examples and uses the function form to print using both a handle variable and a file name variable:
>
> h = figure; plot(1:4,5:8)
> filename = 'mydata';
> print(h, '-dpsc', filename)
>
> This example works ONLY if you assign filename the literal value 'x'. If you try to assign it a text variable, the command fails with a reference to the handle.
>
> I've also been disappointed with changes to plotting functions such as bar plots, which used to be fast and simple to get nice results just using the defaults. Text concatenation doesn't seem to work the way it used to. Documentation is badly written and unclear. My "outsource" detector is firing.

your example works flawlessly on this r2009b(!)...
what does this yield in your system

which print -all;

us
From: Helen on
Thanks to ImageAnalyst and "us" for your help. I've narrowed it down to something about the text variable (never mind that the error message mentions the figure handle). So ... on my syste

This works:

h = figure(10)
plot(x,y)
fname = 'Bingo'
print(h, '-dpdf', fname)

>> fname
fname =
Bingo

And this also works:

h = figure(10)
plot(x,y)
filename = 'Bingo'
fname = filename;
print(h, '-dpdf', fname)

>> fname
fname =
Bingo

BUT THIS DOESN'T WORK:

h = figure(10)
plot(x,y)
namelist = textread('testfile','%s');
fname = namelist(1)
print(h, '-dpdf', fname)

>> fname
fname =
'Bingo'

So my text variable is wrong but I'm not sure how to fix it.

Thanks again,
Helen


"us " <us(a)neurol.unizh.ch> wrote in message <hkkajd$jmp$1(a)fred.mathworks.com>...
> "Helen " <helenfromsun(a)gmail.com> wrote in message <hkk6v2$dvr$1(a)fred.mathworks.com>...
> > Hi Rune, and thanks for your reply.
> >
> > I tried your suggestion but it didn't work. I am running 2009b which, to be honest, sucks badly compared to earlier versions. Here's a quote from the documentation:
> >
> > "This example combines the previous two examples and uses the function form to print using both a handle variable and a file name variable:
> >
> > h = figure; plot(1:4,5:8)
> > filename = 'mydata';
> > print(h, '-dpsc', filename)
> >
> > This example works ONLY if you assign filename the literal value 'x'. If you try to assign it a text variable, the command fails with a reference to the handle.
> >
> > I've also been disappointed with changes to plotting functions such as bar plots, which used to be fast and simple to get nice results just using the defaults. Text concatenation doesn't seem to work the way it used to. Documentation is badly written and unclear. My "outsource" detector is firing.
>
> your example works flawlessly on this r2009b(!)...
> what does this yield in your system
>
> which print -all;
>
> us
From: ImageAnalyst on
Helen:
Try using sprintf() and fullfile() to build up a proper filename.
By the way, is fname a character array, or a cell array?
-ImageAnalyst
From: Walter Roberson on
Helen wrote:

> BUT THIS DOESN'T WORK:
> h = figure(10)
> plot(x,y)
> namelist = textread('testfile','%s');
> fname = namelist(1)
> print(h, '-dpdf', fname)

namelist will be a cell array, so namelist(1) will be a 1x1 cell array.
If you want the contents of that array (the string), you need
fname = namelist{1}
From: Helen on
Thanks and to be honest I can't answer your question. The array is whatever "textread" creates. I can no longer count the number of 2007 scripts that are now broken. What happened to backward compatibility? For 12 years matlab worked easily and flawlessly over a wide range of conditions and purposes. Now it seems everything is broken. Wow. They even got rid of "nanmean". Or maybe I have to buy the $1000 stats package to get it? Sign me, "disappointed in Palo Alto".

ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <0bb51d64-ee63-4d81-bfbe-0e01a3a3ad43(a)k22g2000vbp.googlegroups.com>...
> Helen:
> Try using sprintf() and fullfile() to build up a proper filename.
> By the way, is fname a character array, or a cell array?
> -ImageAnalyst