problem with if and or

2 vues (au cours des 30 derniers jours)
theo Rodriguez
theo Rodriguez le 20 Avr 2022
Commenté : theo Rodriguez le 20 Avr 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

Réponse acceptée

langrg
langrg le 20 Avr 2022
Modifié(e) : langrg le 20 Avr 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
  1 commentaire
theo Rodriguez
theo Rodriguez le 20 Avr 2022
Thank you very much for your help

Connectez-vous pour commenter.

Plus de réponses (1)

Murugan C
Murugan C le 20 Avr 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
  1 commentaire
theo Rodriguez
theo Rodriguez le 20 Avr 2022
Thank you very much for your help

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by