Loops matrix to find zero then cancel the rows relative and create a new matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Stefht
am 27 Sep. 2017
Bearbeitet: Andrei Bobrov
am 27 Sep. 2017
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
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 27 Sep. 2017
Bearbeitet: Andrei Bobrov
am 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),:)
Weitere Antworten (1)
Kian Azami
am 27 Sep. 2017
Bearbeitet: Kian Azami
am 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,:}
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!