how can ı solve this error ? Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
26 次查看(过去 30 天)
显示 更早的评论
clear all;clc;
y=[2 3 4 5;5 6 7 8]
fid=fopen('myfile.txt','wt');
fprintf(fid,'%d,%d\n',y);
fclose(fid);
0 个评论
采纳的回答
Jan
2015-5-31
Check the success of fopen in every case, under all circumstances, ever, nerver omit this test:
filename = 'myfile.txt';
filepath = cd;
file = fullfile(filepath, filename);
fid = fopen(file, 'wt');
if fid==-1
error('Cannot open file for writing: %s', file);
end
I guess you do not have privileges to write to the current folder.
更多回答(2 个)
Caio Vaz Rimoli
2018-9-4
Just brief comment: I also got this error because I ran out HD memory.
0 个评论
Aparna Komarla
2018-10-2
Creating the directory you are storing the files/data in first might help!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!