How to represent percentage values in Matlab App Designer
4 views (last 30 days)
Show older comments
Is there any easy way to represent percentage values in Matlab App Designer? For example, in excel we can type 8% and it will represent 0.08. I am making a basic calculator and have no idea how to get it to work.
Edit: this is what I have for the percentage button:
app.BResultado.Value=sprintf(‘%.0f%%’),app.BResultado.Value*100);
But when I press let’s say 7. Instead of 0.07 I get 5500%
0 Comments
Answers (1)
Voss
on 2 Apr 2022
Consider the differences in the following commands:
val = '7'
sprintf('%.0f%%',val*100)
sprintf('%.0f%%',str2double(val)*100)
sprintf('%.0f%%',str2double(val)/100)
sprintf('%0.2f%%',str2double(val)/100)
sprintf('%0.2f',str2double(val)/100)
Should the result be '0.07' or '700%' (because your code suggests '700%' but your description of the problem suggests '0.07')? You can pick the command that does the right thing.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!