Invalid File Identifer - Help
10 views (last 30 days)
subject_number = input('Subject Number?'); %will prompt for subject number in the command window
filename = ['IntrinsicAttention' num2str(subject_number) '.txt']; %creating the text file name with subject number
fid = fopen(filename, 'w'); %append instead overwrite
fprintf(fid, 'q1col, q2col, q3col, q4col, q1tri, q2tri, q3tri, q4tri,tarmatch, RT') %top header, specifying the variables the columns represent
This code is supposed to create a text file. When I run it though I get an error "Invalid file identifier. Use fopen to generate a valid file identifier." I think it means it cannot create a directory. Looking at other answers, I tried changing the 'w' value, to 'wt' and 'a+' but that didn't seem to help.
Does anyone have any idea how to fix this?