GUI Matlab Arithmetic Calculator

I have button for numbers but I don't know how to make them display on the editbox. For example, when I press 1, it doesn't get displayed on the editbox and i don't know which function I should be using to have that done.

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 12 月 16 日
編集済み: Walter Roberson 2021 年 12 月 16 日

0 投票

assuming integer inputs
Fetch the current value associated with the edit box. Multiply it by 10, and add the value associated with the key pressed. Set the edit box to that value.
If you are using traditional figures, set the uicontrol edit box 'String' property.
If you are using uifigure, set the uieditfield() 'Value' property; https://www.mathworks.com/help/matlab/ref/uieditfield.html
If you are not assuming integer inputs, then you need to keep track of whether the user has pressed the decimal point yet; if so then you have to keep track of how many digits have been entered after the decimal point, and multiply the new value by the appropraite power of 10.

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

タグ

質問済み:

2021 年 12 月 16 日

編集済み:

2021 年 12 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by