Obtaining a logic vector (?) from a logic array

1 vue (au cours des 30 derniers jours)
Mert Emrem
Mert Emrem le 24 Oct 2021
Commenté : Mert Emrem le 24 Oct 2021
A v
[0 0 0 0] |0|
[1 0 0 0] |1|
[1 1 0 1] -> |1|
[0 0 0 0] |0|
[0 1 1 0] |1|
What I am looking for: n'th element of column vector v is 1 if any member of n'th row of the array A, if else 0.

Réponse acceptée

the cyclist
the cyclist le 24 Oct 2021
A = [0 0 0 0;
1 0 0 0;
1 1 0 1;
0 0 0 0;
0 1 1 0];
v = any(A,2)
v = 5×1 logical array
0 1 1 0 1
  1 commentaire
Mert Emrem
Mert Emrem le 24 Oct 2021
Works like a charm, thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by