필터 지우기
필터 지우기

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

채택된 답변

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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by