Effacer les filtres
Effacer les filtres

if statement - working with characters

65 vues (au cours des 30 derniers jours)
Ojaswita
Ojaswita le 23 Sep 2013
Commenté : Gwangil Mun le 26 Nov 2022
I am executing the following code:
x = inputdlg({'Month', 'Population renewal', 'Death rate'}, 'Inputs')
f = getfield(x,{1});
if (f == 'January')
b = 0.5
else
b = 0.7
end
and I am getting an error that says "??? Undefined function or method 'eq' for input arguments of type 'cell'"
Please do tell me where I am going wrong....

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 23 Sep 2013
Use
if isequal(f{1} ,'january')
  7 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 24 Sep 2013
any(strcmp(f,{'janury','march'}))
Gwangil Mun
Gwangil Mun le 26 Nov 2022
good

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings 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