Hello,
My
handles.Value = '1.42'
I'm trying to print this to a text file using:
printf(fileID,'%3.2s',handles.Value)
but it keeps printing '3'
If I try to change '%3.2s' do anything, I end up getting different values that are not '1.42'
What am I doing wrong?
Thanks

 採用された回答

Bhaskar R
Bhaskar R 2020 年 3 月 17 日
編集済み: Bhaskar R 2020 年 3 月 17 日

0 投票

if handles.Value is a string
fprintf(f,'%s',handles.Value);
if handles.Value is a float value
fprintf(f,'%3.2f',str2num(handles.Value));% float to print as 3 field width and 2 precisions

1 件のコメント

Dc215905
Dc215905 2020 年 3 月 17 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2020 年 3 月 17 日

コメント済み:

2020 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by