필터 지우기
필터 지우기

Filtering the contents of an array

조회 수: 16 (최근 30일)
Abinav
Abinav 2020년 7월 10일
댓글: Abinav 2020년 7월 10일
I have an array 'Z' with 'n' rows and 3 columns as a result of 'n' iterations. I need to filter the array based on the third column and store the values in a separate array.
I tried to use create a logical array with condition but then it gave me only a single column. So, I used concatenation to get a nx3 array and then I used element wise multiplication to remove all the unwanted values. But still, I have an nx3 array with rows of zeros inbetween that I need to eliminate. How should I proceed? I am stuck with logical arrays and array multiplications.
A = Z(:,3) >= R_val;
B = cat(2,A,A,A);
C = Z.*B;
PS: I tried using the logical array as array index but it yields a column vector nullifies the total relationship between the rows. So, that doesn't work.
C = Z(B);

채택된 답변

madhan ravi
madhan ravi 2020년 7월 10일
filtered = Z(A, :)
  댓글 수: 1
Abinav
Abinav 2020년 7월 10일
Thanks. I didn't expect it to be that simple.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by