From: Nilesh on 13 Aug 2010 10:53 Hello, Hoping the following may be useful get fopen to work. The code first gave fid=-1 (means file not read). Then it was fid=3 (means file read), but was returning zero value. I have created a matrix of file names. And was trying to open the files using the names form this matrix (all placed in same directory). The following worked: h = char(file_matrix(x,y)) fid=fopen('h') data=textscan(fid, '%f %s') fclose(fid) The fopen did not need any quotes. Thanks, Nilesh matthew.betti(a)gmail.com wrote in message <413d9aa4-7b96-4b39-8ebf-1073ecf3e138(a)w7g2000hsa.googlegroups.com>... > Hello, > > I'm relatively new to Matlab. I'm attempting to import many files, > apply a function to them, then export them to a different directory > but I would like them to have the same filename as the individual > input files. I'm attempting to use textscan to import, but Matlab > gives the files fid= -1 then tells me that the fid is invalid. The > code I have written for this is as follows: > > files=dir(*.dat); > for k=3:10 > fname=files(k).name > fid = fopen(fname,'r') > C = textscan(fid, '%f %f %f %f %f %f %f %f %f %f > %f','delimiter',',','headerlines', 8); > > is there something I am missing here that it returns a fid of -1? > Also is there a similar process for exporting multiple files in the > same fashion as they have been imported? > > Thanks for the help!
|
Pages: 1 Prev: Neural Networks weights and bias help Next: function outputs |