Loops matrix to find zero then cancel the rows relative and create a new matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
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,:}
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!