error using fopen

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일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2012년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by