Thread Subject: invalid file identifier

Subject: invalid file identifier

From: Juliette Salexa

Date: 3 Jun, 2009 23:11:01

Message: 1 of 3

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

Subject: invalid file identifier

From: Donn Shull

Date: 4 Jun, 2009 00:04:01

Message: 2 of 3

"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

Subject: invalid file identifier

From: Juliette Salexa

Date: 4 Jul, 2009 20:22:01

Message: 3 of 3

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

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com