필터 지우기
필터 지우기

fprintf (fid , ) , convert num2str and how to print ?

조회 수: 7 (최근 30일)
Adam Aust
Adam Aust 2014년 3월 1일
편집: Adam Aust 2014년 3월 15일
plz
i need to print x value as a string (text) in a file how
should convert num2str
and then fprintf(fid , ) how ?

답변 (1개)

dpb
dpb 2014년 3월 1일
You don't say how you want x printed but you don't need num2str at all. In fact, if you just want a table of the ending array x, probably using dlmwrite is the simpler solution.
dlmwrite('output.txt', x, 'delimiter', ' ', 'precision','%10.5f')
Salt to suit on format, delimiter, etc., ... see
doc dlmwrite % for details
W/ low-level fprintf it'd be sotoo
fid=fopen('output.txt','w');
fprintf(fid,[repmat('%10.5f ',1,size(x,2)) '\n'], x.');
fid=fclose(fid)
NB: the .' transpose operation to get in row-major order and the explicit formatting.
doc fprintf % and friends for details/examples...

카테고리

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