remove specific rows by referencing on the first digit of each row.

1 vue (au cours des 30 derniers jours)
JL
JL le 9 Sep 2019
Commenté : JL le 9 Sep 2019
Hi everyone, I want to reduce remove rows in matrix A, by referencing on the first number in each row to get B. In this case, if the first number is 1, remove the row
A = [1 1 1 0
0 1 1 1
0 1 1 0
1 0 1 0];
Results B =
B =[0 1 1 1
0 1 1 0];

Réponse acceptée

madhan ravi
madhan ravi le 9 Sep 2019
B = A(~A(:,1),:)

Plus de réponses (1)

Fabio Freschi
Fabio Freschi le 9 Sep 2019
index = 1;
% A(:,1) == index finds the rows with specific value (logical indexing)
B = A(A(:,1) == index,:)

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by