필터 지우기
필터 지우기

Remove values from matrix based on another matrix

조회 수: 1 (최근 30일)
Thang  Le
Thang Le 2013년 5월 9일
Hi,
I have matrix A with the dimensions of 45 x 73 x 28. I have matrix B with the dimensions of m x n x p. I would like to remove all the rows in B that contain any values exceeding the corresponding values in A? This means rows to be deleted from B would have m>45 and/or n>73 and/or p>28. Basically A would be the limit for B.
I'm sure this is a common problem and someone must have asked before but I was not able to find the asnwer. Could someone please help?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 9일
B=B(1:45,1:73,1:28)
  댓글 수: 2
Thang  Le
Thang Le 2013년 5월 9일
편집: Azzi Abdelmalek 2013년 5월 9일
Thanks, Azzi. Since the dimensions of A are not static, I did the following:
B=B(1:size(A,1),1:size(A,2),1:size(A,3))
However, this gave me an error: Index exceeds matrix dimensions. Not sure why.
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 9일
편집: Azzi Abdelmalek 2013년 5월 9일
Try
siz=min([size(A);size(B)])
B=B(1:siz(1),1:siz(2),1:siz(3))

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by