mercredi 1 mai 2019

MATLAB Use contains function within an IF statement

I have a cell array, strings of months in MATLAB. I am using the contains() function to determine if 'Ju' is in the string, along with an if statement, and if the statement is true, then delete 'Ju.' But I am getting an error. The error is: Undefined function or variable 'a'.

Error in Untitled (line 4) if a == contains(months, pattern)

pattern = 'Ju';
months = {'June', 'July', 'August', 'September'};

if a == contains(months, pattern)
    a = regexprep(months, 'Ju', '')
end

Aucun commentaire:

Enregistrer un commentaire