how can I store the values ​​that the user enters in an uieditfield?

1 回表示 (過去 30 日間)
Palma Errico
Palma Errico 2021 年 2 月 22 日
コメント済み: Palma Errico 2021 年 2 月 22 日
i built an array's uieditfield by the app designer code view?. In thi way:
g= app.GridLayout;
% fill array
lbl1 = uilabel(g);
lbl1.Text = 'array 1 '; lbl1.FontSize = 16;
lbl1.Layout.Row = 2;
lbl1.Layout.Column = 1;
for i=1:3
ef = uieditfield(g,'numeric');
ef.Layout.Row = 2;
ef.Layout.Column = i+1;
ef.FontSize = 14;
end
how can i store in a variable the values ​​that the user inserts in an uieditfield??

採用された回答

Mario Malic
Mario Malic 2021 年 2 月 22 日
編集済み: Mario Malic 2021 年 2 月 22 日
Hello,
You can set your ef to be the property of the app.
% This is in properties block
properties(access = private)
ef = gobjects()
end
Reference the property by adding the indexing into app
for i=1:3
app.ef(i) = uieditfield(g,'numeric');
app.ef(i).Layout.Row = 2;
app.ef(i).Layout.Column = i+1;
app.ef(i).FontSize = 14;
end
Access the value for first component with
app.ef(1).Value
  3 件のコメント
Mario Malic
Mario Malic 2021 年 2 月 22 日
編集済み: Mario Malic 2021 年 2 月 22 日
Alright, I see now.
It's a weird interaction between property and a graphic object.
It looks like you have to initialise the ef property as a graphic array, i'll update the code in the answer.
Palma Errico
Palma Errico 2021 年 2 月 22 日
this was precisely the mistake. Thanks so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by