|
Thank you Donn Shull.
I am also having problems with fopen.
filename=test.m
fopen(filename,'r')
works fine.
--
fopen(fullfile('directory1','directory2',filename,'r')) OR
fopen('directory1','directory2',filename,'r') OR
fopen(/directory1/directory2/filename,'r'))
do NOT. (the latter command works in UNIX but not windows).
So how do I open a file that's not in my working directory ??
"Donn Shull" <donn.shull.no_spam@aetoolbox.com> wrote in message <h0731h$bqc$1@fred.mathworks.com>...
> "Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h06vu5$ma1$1@fred.mathworks.com>...
> > fcgr is my own function.
> > -------------------------------------
> > When I do :
> >
> > files = dir('*.fasta');
> > for i =1 : numel(files)
> > gene(i).fcgr = fcgr(files(i).name,1);
> > end
> >
> > Everything works with NO porblems!
> > --------------------------------------
> > When I do :
> >
> > files = dir('../AdifferentDirrectory/*.fasta');
> > for i =1 : numel(files)
> > gene(i).fcgr = fcgr(files(i).name,1);
> > end
> >
> > I get:
> > ??? Error using ==> fread
> > Invalid file identifier. Use fopen to generate a
> > valid file identifier.
> >
> > Error in ==> fcgr at 5
> > st=fread(fid,'uint8=>char'); % read the strings
> > --------------------------------------
> > I can't figure out why, does anybody have any ideas ??
>
> files(i).name just gives the file name not its full path. You could use fullfile to create the full file and path name.
>
> HTH
> Donn
|