MATLAB Answers

fprintf handles.Value?

2 views (last 30 days)
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

  0 Comments

Sign in to comment.

Accepted Answer

Bhaskar R
Bhaskar R on 17 Mar 2020
Edited: Bhaskar R on 17 Mar 2020
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 Comment

David Cunningham
David Cunningham on 17 Mar 2020
Thank you!

Sign in to comment.

More Answers (0)