fid2 opens an existing text file which is empty . I want to write a new line to this empty file. The reason I used a+ is because I want to use fid2 again later inside a loop to add lines to the txt file.
addpath('home/oa/Desktop/T/K')
fid2 = fopen( 'r1.txt', 'a+' );
fwrite(fid2,c1);
The message that appears is
Error using fwrite Invalid file identifier. Use fopen to generate a valid file identifier.
Error in coef (line 70) fwrite(fid2,c1);
What is the problem?
try
[fid2,m] = fopen( 'r1.txt', 'a+' );
then check the content of m