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

2 vues (au cours des 30 derniers jours)
Alejandro Mandujano
Alejandro Mandujano le 29 Mar 2022
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

Réponses (1)

Geoff Hayes
Geoff Hayes le 31 Mar 2022
@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);

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by