I want to read a data pattern from a txt file and concatenate each line together. I wrote the following program but the error message shows:
function read_datapattern(filename)fid = fopen(filename,'rt');if fid < 0 error('error opening file %s\n\n',filename);endpattern = fgets(fid);for n = 1:32767 nextline = fgets(fid); pattern = strcat(pattern, nextline);fprintf(pattern);fprintf('\n');fclose(fid);end
"Invalid file identifier. Use fopen to generate a valid file identifier." "nextline = fgets(fid);"
How do I need to modify the program? Thank you~
Best Answer