필터 지우기
필터 지우기

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

조회 수: 12 (최근 30일)
Adam Luckman
Adam Luckman 2018년 12월 9일
답변: Cris LaPierre 2018년 12월 9일
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