fprintf handles.Value?

조회 수: 10 (최근 30일)
Dc215905
Dc215905 2020년 3월 17일
댓글: Dc215905 2020년 3월 17일
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일
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개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by