I was wondering if anyone knew how to extract a filename from a character array?
I am currently modifying a program and have changed it to run multiple runs without user input (one additional external loop).
Now what i would like to do is input the filenames that i will be outputing to in an array:
fnameindex = ['609-1.txt'; ...
'610-1.txt'; ...
'611-5.txt'; ...
'612-1.txt'; ...
'617-4.txt'; ...
'618-5.txt'];
fname=cellstr(fnameindex);
but when i try and use the: '609-1.txt' as a filename in fopen(fname(1),'wt') it gets an error.
is there a better way to do this? or am i just going to have to type this in each required part of my program?
"Michael LaVigne" <mal209@lehigh.edu> wrote in message <h9ejfs$i1h$1@fred.mathworks.com>...
> Hi everyone,
>
> I was wondering if anyone knew how to extract a filename from a character array?
> I am currently modifying a program and have changed it to run multiple runs without user input (one additional external loop).
>
> Now what i would like to do is input the filenames that i will be outputing to in an array:
> fnameindex = ['609-1.txt'; ...
> '610-1.txt'; ...
> '611-5.txt'; ...
> '612-1.txt'; ...
> '617-4.txt'; ...
> '618-5.txt'];
> fname=cellstr(fnameindex);
>
> but when i try and use the: '609-1.txt' as a filename in fopen(fname(1),'wt') it gets an error.
>
> is there a better way to do this? or am i just going to have to type this in each required part of my program?
>
> Thanks in advance,
> Michael.
Thanks for your reply... i figured this out right as i saw your responce... aparently the {} and () make all the difference with char's
Thanks again-
Michael.
"Godzilla " <godzilla@tokyo.edu> wrote in message <h9enp6$qip$1@fred.mathworks.com>...
> "Michael LaVigne" <mal209@lehigh.edu> wrote in message <h9ejfs$i1h$1@fred.mathworks.com>...
> > Hi everyone,
> >
> > I was wondering if anyone knew how to extract a filename from a character array?
> > I am currently modifying a program and have changed it to run multiple runs without user input (one additional external loop).
> >
> > Now what i would like to do is input the filenames that i will be outputing to in an array:
> > fnameindex = ['609-1.txt'; ...
> > '610-1.txt'; ...
> > '611-5.txt'; ...
> > '612-1.txt'; ...
> > '617-4.txt'; ...
> > '618-5.txt'];
> > fname=cellstr(fnameindex);
> >
> > but when i try and use the: '609-1.txt' as a filename in fopen(fname(1),'wt') it gets an error.
> >
> > is there a better way to do this? or am i just going to have to type this in each required part of my program?
> >
> > Thanks in advance,
> > Michael.
>
> fopen(fname{1},'wt')
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.