How do you make the percentage button work on a basic calculator

2 ビュー (過去 30 日間)
Alejandro Mandujano
Alejandro Mandujano 2022 年 3 月 29 日
Hi. I'm making a calculator on MATLAB and wondering how to get the percentage button to work like on a regular calculator that when upon pressed it converts it into a decimal. Here is the only thing I have so far. Note, I'm in Mexico that's why some words are in spanish:
dato =strcat(app.BResultado.Value, '%');
app.BResultado.Value=dato;
BResultado is what's displayed on screen

回答 (1 件)

Geoff Hayes
Geoff Hayes 2022 年 3 月 31 日
@Alejandro Mandujano - don't you just want to divide the number by 100? So (assuming your BResultado is a text (not numeric) field, then you would do something like
dato = str2double(app.BResultado.Value);
dato = dato / 100.0;
app.BResultado.Value = num2str(dato);

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by