problem with if and or
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
theo Rodriguez
am 20 Apr. 2022
Kommentiert: theo Rodriguez
am 20 Apr. 2022
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
0 Kommentare
Akzeptierte Antwort
langrg
am 20 Apr. 2022
Bearbeitet: langrg
am 20 Apr. 2022
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
Weitere Antworten (1)
Murugan C
am 20 Apr. 2022
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
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!