how to use similar push button in a loop for saving numbers from edit box in matlab GUI

2 ビュー (過去 30 日間)
Hi,
I am new at matlab GUI. Actually I have to take multiple input values from a edit box in such a way that when ever I press the push button it takes the value from edit box and save into first coulumn of an array now when I put other num in the same editbox and push pushbutton it will save that value into second column of the same array and so far it will continue untill I use other push button to save the whole array. Can any body help me how can I do that.
test1.png

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 23 日
編集済み: Adam Danz 2019 年 8 月 27 日
When a callback function in invoked, all of the variables within the callback function are created in its own workspace. When the function completes, all of those variables go away forever unless you save them somewhere. So every time you press the pushbutton, you need to store the current value as a vector that you save somewhere. A common solution is to store data within the "UserData" property of some graphics object within your GUI.
Here's an example that stores the vector within the UserData property of the numeric text field.
function ButtonPushed(app, event)
% store new value at the end of the vector
aap.EditField.UserData(end+1) = app.EditField.Value;
% reset the edit field back to it's default value (if needed)
app.EditField.Value = 0;
end
You can clear the vector from memory like this
aap.EditField.UserData = []; % reset vector

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by