Jana Smith
Jana Smith

Reputation: 27

Matlab Obtain output of GUI listbox

This is my first real time using a gui so I'll try my best to explain. I've created a simple gui that contains 2 different listboxes which contain several variables that happen to be arrays that I created earlier in my code. I want to be able to take the variables that the user selected in the listboxes and use them elsewhere in my code. For example, I have:

Listbox one containing A, B, C
and
Listbox two containing X, Y, Z
In the GUI

and I want to take the arrays the user selects and perform the following interactions with them:

resultA=intersect(Res,output1);
resultB=intersect(Res,output2);

So if they select 'A' in the first one it would essentially do:

resultA=intersect(Res,A);

I've mostly been using Matlab's interactive "guide" as I learn how to do this.

Upvotes: 0

Views: 46

Answers (1)

Tim Adams
Tim Adams

Reputation: 156

Let's call your listboxes h.ListBox1 and h.Listbox2.

To get the output, you would do the following:

StrA=get(h.List1ox1,'String'); resultA=StrA{get(h.ListBox1,'Value')};

You could do the same for the other listbox and continue with your code.

Upvotes: 1

Related Questions