Small issue with some selection

2 次查看(过去 30 天)
Two popup's and one edit text box
First popup
function popupmenu1_Callback(hObject, eventdata, handles)
AUDI = {'Jhon', 'Maria'};
SKODA = {'Jhon', 'Maria', 'Nick'};
MERCEDES = {'Nick'};
% Get car model
selectedCar = handles.popupmenu1.Value;
% Fill owners popup with corresponding list of owners for that model of car.
switch selectedCar
case 1
owners = AUDI;
case 2
owners = SKODA;
case 3
owners = MERCEDES;
end
% Fill owners popup with Audi owners.
str = [];
for k = 1 : length(owners)
str = fprintf('%s\n%s', str, owners{k});
end
handles.edit1.Max = 2; % I think you need this for it to allow a multi-line edit text box.
handles.edit1.String = owners;
Second popup
function popupmenu2_Callback(hObject, eventdata, handles)
AUDI = {'Jhon', 'Maria'};
SKODA = {'Jhon', 'Maria', 'Nick'};
MERCEDES = {'Nick'};
% Get car model
selectedCar = handles.popupmenu2.Value;
% Fill owners popup with corresponding list of owners for that model of car.
switch selectedCar
case 1
owners = AUDI;
case 2
owners = SKODA;
case 3
owners = MERCEDES;
end
% Fill owners popup with Audi owners.
str = [];
for k = 1 : length(owners)
str = fprintf('%s\n%s', str, owners{k});
end
handles.edit1.Max = 2; % I think you need this for it to allow a multi-line edit text box.
handles.edit1.String = owners;
I have a new question for this code
What if ,when I select AUDI and MERCEDES, I want it to show me only if the owners who own both types of cars, if not, to show me message: "no owners who own both types of cars" ? In this case the message will be: no owners who own both types of cars
When I select AUDI and SKODA, I want it to show me only if the owners who own both types of cars , in this case Jhon and Maria.
Thank you!
  1 个评论
Cristian Martin
Cristian Martin 2022-5-15
I guess it could be rezolved with ismember but I dont figure how to apply it...

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by