Instead of using only the file name in
fid = fopen('result.txt','wt+');
use the complete directory path
fid = fopen('/home/gaurav/matlab/OCR/result.txt','wt+');
문제
I am trying to write to a text file "result.txt" using the following matlab code in ubuntu 13.10
fid = fopen('/home/gaurav/matlab/OCR/result.txt','wt');
fprintf(fid,'asdasd');
fclose(fid)
I have changed the permission of file to 777, but nothing is happening.
I changed the 3rd line to
fprintf(fid,'%s','asdasd');
it worked, but now I changed it to
I am sorry it worked the first time, but after modifying it
fid = fopen('result.txt','wt+');
s='Allison Jones';
d='Development ';
fprintf(fid,'%s\n',s);
fprintf(fid,'%s\n',d);
fclose(fid);
clc;clear;
the file is not being modified.
해결책
Instead of using only the file name in
fid = fopen('result.txt','wt+');
use the complete directory path
fid = fopen('/home/gaurav/matlab/OCR/result.txt','wt+');