how to search about a matrix in a cell?
Mostra commenti meno recenti
Hello,
Suppose that I have the cell matrix A which contains the following elements:
A={
[0;0] [0;1]
[1;0] [0;0]
}
So I want to use a line of code that can count how many [0;0] are in each row ?
Regards,
Risposta accettata
Più risposte (1)
madhan ravi
il 19 Gen 2019
Modificato: madhan ravi
il 19 Gen 2019
Sarah's (OP) example:
A={ ...
[0;0] [0;1]
[1;0] [0;0]
};
counts=nnz(~cellfun(@any,A))
Gives:
counts =
2
Stephen's example:
A={[0;0] [0;1] [1;0] [0;0] [0;0]};
counts=nnz(~cellfun(@any,A))
Gives:
counts =
3
5 Commenti
consider:
A={[0;0] [0;1] [1;0] [0;0] [0;0]}
isnt your code doing the opposite of what the op asked for? i would expect a result of 3 for this case.
madhan ravi
il 19 Gen 2019
See edited answer.
Sarah A
il 19 Gen 2019
madhan ravi
il 19 Gen 2019
check the edited answer
Sarah A
il 19 Gen 2019
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!