I have a m.file which looks something like this.
for p = 1:2 if p==1 [data,txt,raw]=xlsread('subject_1.xlsx');%%this is reading file of subject 1
fid4=fopen('new_1_datafile.dat','w'); end if p==2 [data,txt,raw]=xlsread('subject_2.xlsx'); %%%%%%reading file of subject 2
fid4=fopen('new_2_datafile.dat','w')' end ... ... %%%written fid1,fid2,fid3 datafiles
... ... ... %%%there are lots of lines where i calculate different things for each subjects (there are 72 different %%%subjects but for simplicity i am just trying with 2).
fprint(fid4,.......) %%%printing out some important data fclose(fid1) fclose(fid2) fclose(fid3) fclose(fid4)end
how can i make sure the fid4 file for the first subject is cleared before writing fid4 file for the second subject? With the above code, I am getting an error message which says, 'error using open, too many input arguments'. The error shows in line 8 when opening fid4 for second subject. So I think it is because I am opening the same file again for the second subject which has been already written for the first subject. But I have allocated different datafile name for the fid4 files for the 2 subjects. Why am I getting this error?
Best Answer