From: Helen on
Thanks Walter. Not sure if this reflects another change-for-the-worse in matlab 2009 or perhaps an imperfect understanding of textread() I've had all along. I have scripts that treat its output like string vars and all worked nicely in the past. Oh well, thanks again and I assume this will fix it.

Regards,
Helen

Walter Roberson <roberson(a)hushmail.com> wrote in message <hkl8o4$qkd$1(a)canopus.cc.umanitoba.ca>...
> 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: Steven Lord on

"Helen " <helenfromsun(a)gmail.com> wrote in message
news:hkk3at$8mo$1(a)fred.mathworks.com...
> This has to be something people do every day, and yet the documentation
> does not describe it correctly.
> I want to save a figure to file with a variable file name (composed from a
> data group and a number). The following doesn't work because matlab
> reads 'filename' as a literal not a variable.
> print '-pdf' filename

That is correct. This is known as command-function duality -- you can call
most functions as though they were commands.

> The documentation says to use the functional form and gives the following
> as an example:
> print('-dpdf', filename)
>
> Using this generates the matlab error
>
> "??? Error using ==> print at 325
> Handle input argument contains non-handle value(s).
>
> Error in ==> printtest at 103
> print('-dpdf', filename)"
>
> Adding the handle reference 'gcf' (with or without quotes) gets the same
> error.

Looking at some of the later threads, I think I know what the problem is.
Set a breakpoint on line 103 of your printtest script/function (click on the
little line to the right of the line number in the Editor; you should see a
red dot appear on that little line.) Then run printtest, and when you see
the green arrow on that line go to the Command Window and type "whos
filename".

If you see the word "cell" in the Class column, then the problem is that
PRINT expects its inputs to be strings -- char arrays -- but you're passing
it a cell array containing a string. In that case, replace the line of
code:

print('-dpdf', filename)

with:

if iscell(filename)
print('-dpdf', filename{1});
else
print('-dpdf', filename);
end

That will call PRINT with the contents of the filename variable (if it is a
char array) or the contents of the first cell of the filename variable (if
it is a cell array.)

In any case, PRINT should display an error message that more clearly
indicates the cause of the problem when you pass a cell array in -- I will
enter that into our bug database.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Steven Lord on

"Helen " <helenfromsun(a)gmail.com> wrote in message
news: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.

I am sorry to hear you feel that way. Are there particular problems (aside
from this one) that you've run into? If so, you should send your feedback
to Technical Support and/or your sales representative.

> 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.

I can assure you, we're not outsourcing. We do sometimes make changes that
we hope make our products more powerful, more usable, and/or more efficient
(and that sometimes is a trade-off for one of those considerations against
the others) -- again, if you feel that we haven't succeeded, please give us
your feedback on what you feel we should improve (and what you feel we've
done well.)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Steven Lord on

"Helen " <helenfromsun(a)gmail.com> wrote in message
news:hkpak1$q71$1(a)fred.mathworks.com...
> Thanks and to be honest I can't answer your question. The array is
> whatever "textread" creates.

More than likely, in your situation, it's being returned as a cell array due
to the format of your file and/or the format specifier you're passing into
TEXTREAD.

> I can no longer count the number of 2007 scripts that are now broken.
> What happened to backward compatibility?

Backwards compatibility is still extremely important. If something that we
changed that broke your work, TELL US so that when or if we're considering
making a similar change in the future, we can take into account the fact
that we once broke backwards compatibility with a similar change when
determine whether to make thte change or how to inform users about the
change.

> 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".

NANMEAN is and has always been (well, at least as far back as I'm aware)
part of Statistics Toolbox.

http://www.mathworks.com/access/helpdesk/help/toolbox/stats/nanmean.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Walter Roberson on
Helen wrote:
>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".

The earliest reference that I can find to nanmean in this newsgroup is
December 27 2007, and it was referenced as being part of the stats toolbox then.

It appears you can get a free version of nanmean et al. from the Matlab File
Exchange,
http://www.mathworks.com/matlabcentral/fileexchange/6837