For loop with string comparison

1 Ansicht (letzte 30 Tage)
HABILA
HABILA am 20 Jul. 2020
Kommentiert: HABILA am 20 Jul. 2020
I am getting error with this code. Can someone help me with this ?
for i=1:100
if (S(i).Status=='Active' || S(i).type=='N')
disp(i)
else
continue;
end
end

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 20 Jul. 2020
Change to
...
if strcmp(S(i).Status,'Active') || strcmp(S(i).type,'N')
...
end
  1 Kommentar
HABILA
HABILA am 20 Jul. 2020
This one worked, Thank U so much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by