So for a project that I am doing that requires programmatic GUI development (I cannot use the App Designer), I am trying to write a program that can read single letter inputs from multiple editable text boxes and put them into an array to be used later on. I found some code posted by Walter Roberson in 2013 that successfully created the boxes using a for loop, but now i don't know how to read the inputs in the boxes.
Here is the part that creates the text boxes:
np1 = 5;
editp1 = zeros(np1,1);
for K = 1:np1
editp1(K) = uicontrol( 'Style', 'edit', 'Units', 'normalized', 'Position', [(0.1+((K-1)*0.04)) 0.7 0.04 0.07]);
end
How would i program a push button to write the inputs of the text boxes into an array at the push of said button? I know it will use a callback function but i have no idea what that would look like nor what outputs would go on the button code itself.

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 4 月 20 日
編集済み: Cris LaPierre 2021 年 4 月 20 日

0 投票

You need a handle to each object so that you can access its properties.
Consider reviewing the examples on the uieditfield documentation page. Several of them show how to create handles.

4 件のコメント

Jack Georege
Jack Georege 2021 年 4 月 20 日
So will I be able to modify the for loop to accomodate this? And how would I go about reading the handles in a callback function?
Cris LaPierre
Cris LaPierre 2021 年 4 月 20 日
It's all in how you define your callbacks. See this example.
You may want to take a hint from how GUIDE and now App Designer and capture these handles in a structure. That structure can be an input to your callback functions. Since the structure contains a handle to all componenents, you can use it to access the properties of all of them from within any callback functino.
Jack Georege
Jack Georege 2021 年 4 月 20 日
Ok I'll give it a try, again I'm not allowed to use App Designer or anything like that for this class but I'll take a look at the examples and see what I can do. I'll reply to this again if i run into any trouble.
Thanks for the help!
Cris LaPierre
Cris LaPierre 2021 年 4 月 20 日
編集済み: Cris LaPierre 2021 年 4 月 20 日
If you reread what I posted, you'll see I'm not telling you to use Guide or App Designer.
The link I sent you to is a subpage under the topic "Develop Apps Programmatically". Perhaps that is the best place for you to begin.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Develop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by