Effacer les filtres
Effacer les filtres

Loops matrix to find zero then cancel the rows relative and create a new matrix

1 vue (au cours des 30 derniers jours)
Dear all, I try to prepare this file, anyone can help me? I want to loop a matrix A, looks that if in the 3rd row there is a zero, cancel the relative rows and store data in a new matrix. I give you an example in the picture... Thanks a lot

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 27 Sep 2017
Modifié(e) : Andrei Bobrov le 27 Sep 2017
for "B = NEW Matrix without zero"
A = [104.727 114.779 0
104.801 97.8394 0
105.1 102.3 0
87.6095 93.4037 0.163248
91.8576 93.4104 0.029488
96.1126 93.4671 0
87.6694 97.6533 0.180924
91.9401 97.6864 0.039721
96.2027 97.7459 0
87.7357 101.9 0.185101
92.0101 101.944 0.042793
96.2988 102.044 0
87.7763 106.141 0.186195
92.0666 106.206 0.044089
96.3472 106.314 0
92.103 118.801 0.038451 ];
B = A(all(A,2),:)

Plus de réponses (1)

Kian Azami
Kian Azami le 27 Sep 2017
Modifié(e) : Kian Azami le 27 Sep 2017
Hello,
If A is a Matrix you can simply do it by the following command:
B = A(A(:,3) ~= 0,:)
if A is Table:
B = A{A{:,3} ~= 0,:}

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by