error using fopen

1 次查看(过去 30 天)
kash
kash 2012-5-2
i have some values in loop ,when writing it to a text pad i get as
6.000000[]7.000000[]
i need only as 6 and 7
fprintf(fileID,'%1f\n',num)
please help

回答(1 个)

Richard
Richard 2012-5-2
what about:
a = [6,7];
filename = 'E:\test.txt';
fid = fopen(filename,'wt');
fprintf(fid,'%g\t%g',a);
fclose(fid)
By using %g this will leave no trailing zeros.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by