format numbers in plot

hi
i am using text command to show variable value in plot
but i am not able to format this variable (format short)
text(5,3,['variable value=',char(a)]) i get variable value = 0.324546494654894846156486494646
so how to format it to 0.32454

 Accepted Answer

instead of your char(a)
I would use
num2str(double(a), 6)
or
sprintf('%0.6f', double(a))

3 Comments

i have used both they give this error
??? Error using ==> sprintf
Function is not defined for 'sym' inputs.
See my edit. I missed your "a" was a sym. You need to convert the sym to a double first.
thankx it works

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!