f



Saving figure error (invalid argument)

I've searched through the newsgroup archives for an answer to my question, and I've read through FAQ 4.12, but I still can't find a solution to my particular issue.

I'm trying to automate the saving of a figure as .fig.  It is in a loop which changes the figure's filename with each iteration of the loop.  Here's the relevant portion of code:

figname = sprintf('%s_%s_%s\b\b\b\b', EEG.chanlocs(currChan1).labels, EEG.chanlocs(currChan2).labels, currfile); 

figname = Fz_Cz_STROOP0037

figure;

saveas(gcf, figname, 'fig');

------
Everything works beautifully until the saving.

Thanks,
Nick
0
Nicolas
4/18/2010 6:23:06 PM
comp.soft-sys.matlab 211266 articles. 21 followers. lunamoonmoon (257) is leader. Post Follow

4 Replies
1195 Views

Similar Articles

[PageSpeed] 18

What's the problem?  Didn't it add the .fig extension?  Try
putting .fig into the end of your format string in your printf().  And
what's the point of the 4 \b's?
0
ImageAnalyst
4/18/2010 8:16:29 PM
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7b25bb23-61c2-46d3-9d26-e99b8bd23d61@c1g2000vbc.googlegroups.com>...
> What's the problem?  Didn't it add the .fig extension?  Try
> putting .fig into the end of your format string in your printf().  And
> what's the point of the 4 \b's?

I put the \b's in there because I only needed a portion of the string (it is used in its full form in other functions of the script).  I tried your idea, but it gave me a similar response as my original:

??? Error using ==> save
Unable to write file Fz_Cz_STROOP0037.fig: Invalid argument.

Error in ==> hgsave at 239
save(filename, 'hgS_070000',varargin{save_args:end});

Error in ==> general\private\saveasfig at 7
hgsave( h, name );    

Error in ==> saveas at 130
    feval( ['saveas' format], h, name )

Error in ==> coherence at 59
            saveas(gcf, figname);
----------------
Your thoughts?

Thanks,
Nick
0
Nicolas
4/19/2010 12:07:04 AM
Nick:
Does it work if you hard code the name Fz_Cz_STROOP0037.fig in there?
Maybe that weird \b stuff is messing it up - you don't see it but it's
there as hidden characters.  Why don't you just use regular indexing
like currfile(1:end-4) to get all but the last 4 chars, instead of the
full currfile and 4 backspaces (which is kind of weird - I've not seen
that before)?
0
ImageAnalyst
4/19/2010 12:37:59 AM
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <280e5ef9-235d-4640-89ca-0b2f01572fd8@i12g2000vba.googlegroups.com>...
> Nick:
> Does it work if you hard code the name Fz_Cz_STROOP0037.fig in there?
> Maybe that weird \b stuff is messing it up - you don't see it but it's
> there as hidden characters.  Why don't you just use regular indexing
> like currfile(1:end-4) to get all but the last 4 chars, instead of the
> full currfile and 4 backspaces (which is kind of weird - I've not seen
> that before)?

Ah ha! Worked wonderfully. Thanks for the tip.  It must have been the \b's messing it up.
0
Nicolas
4/19/2010 12:55:08 AM
Reply: