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

12 次查看(过去 30 天)
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.

采纳的回答

Cris LaPierre
Cris LaPierre 2018-12-9
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by