array operation in matlab

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 Language Fundamentals in Help Center and File Exchange

Asked:

on 14 Feb 2022

Edited:

on 14 Feb 2022

Community Treasure Hunt

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

Start Hunting!