array operation in matlab

1 view (last 30 days)
ali hassan
ali hassan on 14 Feb 2022
Edited: Matt J on 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?

Accepted Answer

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

More Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!