how to search about a matrix in a cell?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sarah A
am 19 Jan. 2019
Kommentiert: Sarah A
am 19 Jan. 2019
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,
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
madhan ravi
am 19 Jan. 2019
Bearbeitet: madhan ravi
am 19 Jan. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical 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!