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

2 ビュー (過去 30 日間)
Stefht
Stefht 2017 年 9 月 27 日
編集済み: Andrei Bobrov 2017 年 9 月 27 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 9 月 27 日
編集済み: Andrei Bobrov 2017 年 9 月 27 日
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),:)

その他の回答 (1 件)

Kian Azami
Kian Azami 2017 年 9 月 27 日
編集済み: Kian Azami 2017 年 9 月 27 日
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,:}

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by