필터 지우기
필터 지우기

How do i add tolerance to the code. PLS HELP.

조회 수: 1 (최근 30일)
Sarthak Jakar
Sarthak Jakar 2022년 4월 2일
댓글: Sarthak Jakar 2022년 4월 3일
MIE is has 3501 values inside it and MIE_2 is a single value. I am trying to find the index of MIE_2 value inside the MIE with next closest possible value so as to plot it using indexing. since MIE_2 us calculated using expression, upto 4 decimals it does not match with values in MIE.
tol = 0.0001;
MIEIdx = find(MIE == (MIE_2),1,'first');

채택된 답변

Walter Roberson
Walter Roberson 2022년 4월 2일
MIEIdx = find(abs(MIE_2 - MIE) <= tol);
This might have 0 or more matches.
You might also be interested in
[dist, MIEIdx] = min(abs(MIE_2 - MIE));
if dist > tol
%no match
else
%MIEIdx is the match
end
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 4월 3일
No, that first code finds all of the values that are within the tolerance, not just the nearest.
Sarthak Jakar
Sarthak Jakar 2022년 4월 3일
Oh yes, when i run it for different data it gives me 4-5 values with accuracy described as per the tolerance. But it still works for me. thanks.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by