Small issue with some selection

조회 수: 2 (최근 30일)
Cristian Martin
Cristian Martin 2022년 5월 15일
댓글: Cristian Martin 2022년 5월 15일
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