Azzera filtri
Azzera filtri

if statement - working with characters

61 visualizzazioni (ultimi 30 giorni)
Ojaswita
Ojaswita il 23 Set 2013
Commentato: Gwangil Mun il 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....

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 23 Set 2013
Use
if isequal(f{1} ,'january')
  7 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 24 Set 2013
any(strcmp(f,{'janury','march'}))

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by