필터 지우기
필터 지우기

Why getting NaN's and other garbage from interp1?

조회 수: 9 (최근 30일)
Todd Welti
Todd Welti 2021년 11월 27일
댓글: Star Strider 2021년 11월 28일
I have had my fair share of times when I got weird results form using interp1. Usually I'd find a hidding NaN somewhere or maybe some weird spline behavior. This time I'm stumped. my source data is clean, no NaNs in my underlying values or desired extrapolated values. I' not extrapolating even. I tried several methods and keep getting weird results. Should be an easy one! I'm getting Nan's up to 20 Hz (b and c are Hz in my case). The rest of the test variable is mostly NaNs with a few non NaN numbers which seem to have little relation to the source data. I can't understand this!
test = interp1(a,b,c);

채택된 답변

Star Strider
Star Strider 2021년 11월 27일
I am not certain what the problem is (providing the data without the code and interp1 calls is not informative), however unless an interpolation method is provided and 'extrap' is requested, the interpolation functions will return NaN for the extrapolated values (although this varies with the extended-dimension functions). See Extrapolation Using Two Different Methods for details on this.
.
  댓글 수: 2
Todd Welti
Todd Welti 2021년 11월 28일
편집: Todd Welti 2021년 11월 28일
I just realized my error. I have done this once before a long time ago. I reversed the order of the first two variables. For some reason I keep thinking that it should be
(underlaying value, old x value, new x value)
but of course it is not. I should probably remove the question.
Star Strider
Star Strider 2021년 11월 28일
No, please keep the Question posted.
I’ve been active here for about eight years total, although not continuously. The same problems keep occurring, and if someone sees this thread it could provide an immediate solution to a similar problem they they would otherwise have to wait to have a response posted for. One of the benefits of Answers is that it’s a repository of such problems and solutions.
.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by