problem with if and or

조회 수: 3 (최근 30일)
theo Rodriguez
theo Rodriguez 2022년 4월 20일
댓글: theo Rodriguez 2022년 4월 20일
Hello i have a little problem i really don't understand why my code don't open a popup window when i press 'interp'
someone can help me ?
Choix1 = questdlg('Veuillez choisir un mode de fonctionnement du programme :', 'Menu Principal', 'Demo', 'Projet', 'Quitter', 'Quitter');
if Choix1 == 'Projet'
ChoixOption = questdlg('Veuillez choisir un mode de fonctionnement du Projet :', 'Menu du Projet', 'interp', 'zero-padding', 'lineaire', 'lineaire');
end
if ChoixOption == 'zero-padding'
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
elseif ChoixOption == 'interp'
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
endif

채택된 답변

langrg
langrg 2022년 4월 20일
편집: langrg 2022년 4월 20일
Hello,
You should use "strcmp" instead of "==", then end syntax of an "if" condition is "end" not "endif", like that:
Choix1 = questdlg('Veuillez choisir un mode de fonctionnement du programme :', 'Menu Principal', 'Demo', 'Projet', 'Quitter', 'Quitter');
if strcmp(Choix1, 'Projet')
ChoixOption = questdlg('Veuillez choisir un mode de fonctionnement du Projet :', 'Menu du Projet', 'interp', 'zero-padding', 'lineaire', 'lineaire');
end
if strcmp(ChoixOption, 'zero-padding')
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
elseif strcmp(ChoixOption, 'interp')
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
end
  댓글 수: 1
theo Rodriguez
theo Rodriguez 2022년 4월 20일
Thank you very much for your help

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Murugan C
Murugan C 2022년 4월 20일
Hi, to compare string, use strcmpi keyword.
Please find below code.
Choix1 = questdlg('Veuillez choisir un mode de fonctionnement du programme :', 'Menu Principal', 'Demo', 'Projet', 'Quitter', 'Quitter');
if strcmpi(Choix1, 'Projet')
ChoixOption = questdlg('Veuillez choisir un mode de fonctionnement du Projet :', 'Menu du Projet', 'interp', 'zero-padding', 'lineaire', 'lineaire');
end
if strcmpi(ChoixOption, 'zero-padding')
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
elseif strcmpi(ChoixOption, 'interp')
ChoixTaux = questdlg('Veuillez choisir un taux de sur-échantillonage :', 'Menu sur-échantillonage', '2', '3', 'Quitter', 'Quitter');
end
  댓글 수: 1
theo Rodriguez
theo Rodriguez 2022년 4월 20일
Thank you very much for your help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by