array operation in matlab

1 Ansicht (letzte 30 Tage)
ali hassan
ali hassan am 14 Feb. 2022
Bearbeitet: Matt J am 14 Feb. 2022
if i have type cell:
a=['hi' 'lo' 'hi'];
b=['lo' 'hi' 'hi'];
how can i find total number of times when there is 'hi' in a and 'hi' in b as well?

Akzeptierte Antwort

Matt J
Matt J am 14 Feb. 2022
Bearbeitet: Matt J am 14 Feb. 2022
a={'hi' 'lo' 'hi'};
b={'lo' 'hi' 'hi'};
nnz(string(a)=="hi" & string(b)=="hi")
ans = 1

Weitere Antworten (0)

Kategorien

Mehr zu Financial Toolbox 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