MATLAB Answers


The numbers on the listbox do not look the way I want.

Asked by Muhendisleksi on 18 Aug 2017
Latest activity Commented on by Muhendisleksi on 18 Aug 2017
my kod:
x = 3.71044e+06
How can I show it as "x =37104445.345"?


Show what? In the code you have shown you define x after you set it, but since the content of a listbox is a string it will show up exactly as you tell it to. The format used for a number on the command line has no effect over that. You haven't shown what you do to get the x that goes into the listbox.
I get "x = K2 + dx/10000;" with this function and it prints the result.
That still doesn't add anything to the question really. You set a string in the list box. Where is that string defined? Your x there is numeric so you must turn it into a string and how you do that will determine what is shown in the listbox.

Sign in to comment.

1 Answer

Answer by Image Analyst
on 18 Aug 2017
 Accepted Answer

Try this:
x = 3.71044e+06;
s = sprintf('%.3f', x); % Turn x into a string.
handles.listbox1.String = s; % Send string to the listbox control.
Set the fontsize in GUIDE rather than code if you want it to be the same all the time.

  1 Comment

Sign in to comment.