필터 지우기
필터 지우기

how can I print the plus automatically when using sprintf?

조회 수: 3 (최근 30일)
Seba.V
Seba.V 2019년 8월 22일
답변: Guillaume 2019년 8월 22일
I have noticed that when using sprintf the plus is not displayed, can anyone help me find a solution? i just need to print the valueswiththe relative sign.
sprintf('(x%g)(x%g)(x%g)(x%g)(x%g)(x%g)',x1,x2,x3,x4,x5,x6)
Thank you in advance

채택된 답변

Guillaume
Guillaume 2019년 8월 22일
Read the documentation of the formatspec of any of the *printf function. It's explained right there under Flags:
'+' Always print a sign character (+ or –) for any numeric value.
so:
>> sprintf('x(%+g)', 5.2)
ans =
'x(+5.2)'

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by