我正在尝试编写的数据格式为:
write =
[1x100 char]
[1x116 char]
'n'
[1x114 char]
'n'
[1x114 char]
'n'
[1x115 char]
'n'
[1x116 char]
'n'
使用:
fid = fopen('C:/file.txt');
for i = 1:length(write);
fprintf(fid,'%s\r\n',write{i,1});
end
fclose(fid);
我无法解决我做错了什么,有什么帮助吗?
答案 0 :(得分:1)
你需要写:
fid = fopen('C:/file.txt', 'w+');
如果文件不存在而你想写入文件。
答案 1 :(得分:0)
试试这个MATLAB片段......
myfilename = ('yourfilename.txt');
fid = fopen(myfilename,'wt');
if (fid < 0)
error('could not open file "myfilename.txt"');
end;
for i = 1:length(write)
fprintf(fid,' The Stored Details are below : %f ',write{i,1});
end
fprintf(fid,'\n The write values are stored.\n\n');
fclose(fid);