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.

Answers (1)

Walter Roberson
Walter Roberson on 16 Dec 2021
Edited: Walter Roberson on 16 Dec 2021
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.

Categories

Tags

Asked:

on 16 Dec 2021

Edited:

on 16 Dec 2021

Community Treasure Hunt

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

Start Hunting!