In App Designer, how can I ensure that the values displayed on the UI do not appear in scientific notation?

For example, I have a field called app.Profile.Value. Large numbers are often converted to scientific notation. How do I force all values of this variable to be displayed properly, i.e., 1234, instead of 1.234*10^3?

 Réponse acceptée

Where or how are you displaying them? If you're using fprintf or sprintf, use %.3f or %g in your format specifier. If you're just having them echo to the command window, try
> format longg

5 commentaires

Many thanks. My app.Profile.Value is supposed to be a numerial value with Limits set by some numbers. If I use fprintf, the results will be a string, am I right?
No, fprintf prints to a file or the command window. sprintf creates a string. I still don't know where you are seeing scientific notation? Are you saying that if you type 1234 into a numerical edit field (in an App Designer GUI) and hit enter, it will instantly and automatically change it to 1.234*10^3 instead???
Apologies for my delayed response.
I see it on the UI interface I build using App Designer. Attached is a screenshot of it. The number is derived from my data internally. In this case, instead of showing an integer of 25172. It shows 2.517e4.
For that same number, I also enable my users to change it by typing in a new number. For that reason, the type of this variable should be numerical, instead of a string.
Change the ValueDisplayFormat string to %.4f instead of %.4g. If you want integers, use %.0f but that will display integers but the underlying number will still be floating point. You can check the RoundFractionalValues if you want the underlying values to also be integers.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Produits

Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by