MATLAB Answers

how can I print the plus automatically when using sprintf?

1 view (last 30 days)
Seba.V on 22 Aug 2019
Answered: Guillaume on 22 Aug 2019
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.
Thank you in advance


Sign in to comment.

Accepted Answer

Guillaume on 22 Aug 2019
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.
>> sprintf('x(%+g)', 5.2)
ans =


Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by