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!
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!