필터 지우기
필터 지우기

eliminating value out of range

조회 수: 6 (최근 30일)
Mayank Lakhani
Mayank Lakhani 2016년 3월 14일
댓글: Mayank Lakhani 2016년 3월 15일
I have two matrix.
A = rand(8,10);
B = rand(8,41);
range = 0.5345 (y+ direction and y- direction, range of elements of A);
i want to take all elements of B which fall in the range of matrix A 's elements. The elements of B which does not fall in the range should be NaN.
  댓글 수: 2
Matthew Eicholtz
Matthew Eicholtz 2016년 3월 14일
편집: Matthew Eicholtz 2016년 3월 14일
I assume the code snippet you provide is just to demonstrate the size of A and B and not exactly how you create A and B? Because "A = rand(8,10);" will not necessarily yield a range of 0.5345.
Mayank Lakhani
Mayank Lakhani 2016년 3월 15일
yes, you are right.

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

채택된 답변

Image Analyst
Image Analyst 2016년 3월 14일
Declare a logical variable that states when values are in range
inRange = B >= min(A(:)) & B <= max(A(:));
Now assign to nan if outside that range, as you asked:
B(~inRange) = nan;
Or you can extract only those that are in range into a new variable:
BInRange = B(inRange);
Or you can delete those that are not in range, giving a shorter B than the original:
B(~inRange) = [];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by