更新时间:2023-12-01 13:50:10
导致fprintf
失败的主要原因是格式说明符中的%n
.在matlab中,请使用%d
.
The major thing which was making the fprintf
fail was your %n
in the format specifier. In matlab use a %d
instead.
用修改后的格式说明符稍微重写最后一个循环将产生所需的输出:
slightly rewriting your last loop with a modified format specifier will produce the desired output:
%% // write new file
fileout = 'imc_out.txt' ;
fid=fopen(fileout,'wt');
for i=1:length(imc)
fprintf(fid,'%s %d %3.2f %3.1f %s\n',nome{i},peso(i),altura(i),imc(i),imc_ok{i}) ;
end
fclose(fid)