How to set constraints of griddata results are all non-negative?

조회 수: 7 (최근 30일)
Annie
Annie 2019년 8월 18일
답변: Walter Roberson 2019년 8월 18일
I use the griddata function in matlab, but after the interpolation, the value of some points is less than 0. Is there any way to control the range of interpolation results?
That is to say, the results I want are all non-negative, but the results obtained after interpolation are somewhat less than 0.
Is there any way to set constraints?
  댓글 수: 1
Annie
Annie 2019년 8월 18일
I use griddata to interpolate the existing data (61) (the interpolation result is 100), my data is percent, but the result of the interpolation is <0, there are also >100, how to control, so that the interpolation result is Between 0-100?

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

채택된 답변

Stephen23
Stephen23 2019년 8월 18일
편집: Stephen23 2019년 8월 18일
"Is there any way to control the range of interpolation results?"
You could simply adjust the output data yourself:
A = max(0,min(100,A))
Depending on your data values you might be able to change the input data values and/or the interpolation method, e.g. if you used a spline or similar, then you might be able to change for linear interpolation.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 8월 18일
The griddata and interp1 and interp2 methods that do interpolation (so everything except nearest or next or prev) are all subject to "ringing" when there is a sharp transition 0 to 0 to positive, because none of them can handle sharp corners. The piecewise ones such as spline are best at such transitions, but do not always detect the transition at exactly the right boundaries.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by