How to save the input of an edit text box on GUI?

9 views (last 30 days)
I want to have the user input their first value into the edit box, click the save button (saving the input to an array) and then for them to be able to reinput another value in the same box and then that value also being saved in to the array. I want them to be able to do this as many times as they want until they click the calculate button of which a static box will show them the sum of this array.
I cannot seem to figure out how to set up the array inside the callback, as when i try i usually get: 'Array indices must be positive integers or logical values.' Error.

Accepted Answer

Cris LaPierre
Cris LaPierre on 9 Dec 2018
Create a property for storing the values. You don't have to assign it a value, just name it. I named mine "nums"
properties (Access = private)
Nums; % Description
end
Add a callback to your edit field for when the value changes. Create your array by appending the current number to your property variable. This adds it to the top, but you can code this however you want.
% Value changed function: EditField5
function EditField5ValueChanged(app, event)
value = app.EditField5.Value;
app.Nums = [value; app.Nums];
end

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!