How to represent percentage values in Matlab App Designer
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Voss
2022 年 4 月 2 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!