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

조회 수: 1 (최근 30일)
Alejandro Mandujano
Alejandro Mandujano 2022년 3월 29일
댓글: Alejandro Mandujano 2022년 3월 31일
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 CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by