2 popup menus connected

5 次查看(过去 30 天)
Dinouk Goonewardena
评论: Rik 2020-4-1
I'm trying to create 2 popup menus the first one stores all the 'Y numbers' and then depending on that I want to get the corressponding 'Version'. Note some Y numbers have more than 1 version. Hence I need help to figure it out
  10 个评论
Rik
Rik 2020-3-31
Your code will generate a variable of the dataset class (which will apparently be removed in a future release), while your screenshot is of the table datatype. The data also doesn't look remotely similar to me. Should the first dropdown contain 0.1, 0.3, and 0.2, with the second dropdown containing only a single option after the first selection has been made?
Dinouk Goonewardena
编辑:Dinouk Goonewardena 2020-3-31
A better example of data i guess, So the first 2 Y number (1) has 2 versions, which should be in the popupmenu2

请先登录,再进行评论。

回答(1 个)

Rik
Rik 2020-3-31
Ynumber=[1;1;2;3;5];
Version={'AP'; 'AP_R' ;'AP' ;'TI1' ;'TI2'};
mytable= table(Ynumber,Version);
%Y_selected=get(handles.dropdown_Y,'Value');
Y_selected=2;
selected_Ynumber=mytable.Ynumber(Y_selected);
L=ismember(mytable.Ynumber,selected_Ynumber);
versions=mytable.Version(L);
The last variable can be used as the String property of your second dropdown.
  4 个评论
Dinouk Goonewardena
sorry not that line but this;
selected_Ynumber=data_sheet2.YNumber(Y_selected); -----------(Error: Expected one output from a curly brace or dot indexing expression, but there were 12475 results.)
L=ismember(data_sheet2.YNumber,selected_Ynumber);
handles.popupmenu2.String=b(L);
Rik
Rik 2020-4-1
The code I posted works. You can't send me the data you're working with, so you will have to provide example data that will reproduce the error. It seems like Y_selected might not be a scalar, or data_sheet2 is not a table or scalar struct.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by