Error In Printing NaN Data to .txt

3 ビュー (過去 30 日間)
Tyann Hardyn
Tyann Hardyn 2022 年 8 月 21 日
コメント済み: dpb 2022 年 8 月 21 日
Hi Community,
I have a question about printf function in Matlab. Iam using printf function like this below:
hasil_convs_saving_mult = sprintf('Fixed %s Combined Magnetic Data %s %s (%s).txt', savektot_data, mr_mm_tot, convtot_begins_finals, stasiunc_comb);
saving_multfileconvs = fullfile(pathraw, hasil_convs_saving_mult);
foutsaving_multfileconvs = fopen(saving_multfileconvs,'w');
fprintf(foutsaving_multfileconvs,'%s %s %s %s %s %s %s %s %s %s %s %s\n', 'DATE', 'TIME', 'H(Fix)', 'F(Calc_Fix)', 'F(Obs_Fix)', 'D(Fix)', 'X(Fix)', 'Y(Fix)', 'Z(Fix)', tipec_comb, stasiunc_comb, time_conversion);
fprintf(foutsaving_multfileconvs,'%s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n', [waktudate_conv_combi, waktutime_conv_combi, Total_ekstrak_komph, Total_ekstrak_kompfcalc, Total_ekstrak_kompfobs, Total_ekstrak_kompd, Total_ekstrak_kompx, Total_ekstrak_kompy, Total_ekstrak_kompz]') ;
fclose(foutsaving_multfileconvs);
However, the output is so weird. The output of the above code is actually in .txt, but when i opened it in notepad..... It sadly become like this:
Why the ouput become like this, everyone... I realized that the data input was include NaN data in double, but it never like this before.... Would anyone lend me a hand to solve this problem? Is it because of my PC setting or an Error in my code or what? Thank you so much.... /.\ /.\ /.\
  1 件のコメント
dpb
dpb 2022 年 8 月 21 日
Don't use Notepad; try the MATLAB editor -- but looks like an issue with default fonts, maybe. I think fprintf handles NaN, ...well, let's just refresh memory...
>> fprintf('%d\n',nan)
NaN
>>
yes, as I remembered (and has to be)...
There's may be something else going on with what the actual data are, as well and a formatting issue of char() and numerics with correct matching formatting strings -- although MATLAB does its best to create a matching output.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by