Alternative ways for 2D spline interpolation of scattered data
4 次查看(过去 30 天)
显示 更早的评论
theintern
2017-11-2
Hello,
I have scattered data and I use this for interpolation in order to find corresponding values like below. I used all the methods in griddata and have no idea which gives me most reliable results. I also used scatteredInterpolant. What is your suggestion? What are the difference between those methods and which are more reliable?
a=data(:,1)
b=data(:,2)
c=data(:,3)
x=griddata(a,b,c,y,z)
I calculate y and z values and would like to find corresponding x values. For example; in my data
a=3.8 b=0.01 c=2
a=5 b=0.07 c=4
and I calculate with some formulas y=4.2 and z=0.04 and I would like to find what z value is. Thats why I need interpolation.
12 个评论
John D'Errico
2017-11-2
编辑:John D'Errico
2017-11-2
The answer to this can involve writing an entire textbook on interpolation. So essentially, there is no answer to your question, at least not without writing an entire text.
As far as reliability goes, that too is impossible to answer. Were there any perfect method for interpolation, then only one method would need to be provided. Every method will have flaws as well as virtues. And for one problem or another, a specific aspect of a method may be either a flaw or a virtue, depending on the problem posed.
Finally, without even showing what your data looks like, or saying what you need from it, again, we would need to write an entire textbook, covering all possible cases. How do we even know if your problem is even solvable by interpolation methods? Seriously, a fair amount of the time when someone has problems with interpolation, that is because they have no clue as to why what they are trying to do is nonsensical in context of interpolation. No, i'm not going to list the half dozen things I can think of that people commonly do wrong when thinking they want to do interpolation. I could write pages about that alone.
So if you seriously want an answer...
1. You need to provide your data. Don't show a trivial subset of your data, that you think is acceptable, because you know essentially nothing about interpolation methods. So you don't know what you can safely discard.
2. You need to explain what you will be doing with the result of the interpolation. Are you just trying to draw a pretty picture? Will you be using this result for massive computations later, and must predict millions of values through that surface?
3. What do you know about the problem? Is there noise that must be smoothed? Many people have no clue that interpolation is not a way to smooth noise in data.
4. Must you extrapolate beyond the boundaries of the data? In general, this is a bad idea, but it is possible. And however you choose to extrapolate, expect crap as a result if you will be extrapolating at all far out. Different methods extrapolate differently, some not at all.
Etc.
Look at it another way. People think that there is a RIGHT way to do interpolation. You certainly seem to think so from what you have said. That might be closer to truth if you were solving an ODE, for example. Given sufficient information in the form of initial values, an ODE has a solution (usually.) So it is really aquestion of which way is more accurate, faster, efficient under some metric, etc. But there is NO unique solution to any interpolation problem. Given only a set of data points, there will be an infinite number of interpolants, all equally valid, so all equally good in theory.
John D'Errico
2017-11-2
NO. You still have not shown us your data. You gave two data points, that you made up on the spot.
Stephen23
2017-11-2
"have no idea which gives me most reliable results."
None of them. Interpolated data is made-up data, so there is no universal metric for how "reliable" they are, because they are not "reliable" in the first place.
"I ... have no idea which gives me most reliable results"
Like many data processing methods it depends on the data. You have to know the underlying physical model, or statistical model, and you have to pick an interpolation method that suits your data. There is no universal solution.
Eric
2017-11-2
Actually, interpolated data is not (always) "made-up" data. It does not appear that this is what the OP's data is, but interpolation is used all the time in signal processing to convert digital or sampled signals back to analog. Certain conditions must be met in order to do this, but then the results are perfect and reliable, although they are interpolated. However, you must know some underlying information about your signal, which as I said, does not appear to be the case here. See the Nyquist-Shannon sampling theorem for more information.
John D'Errico
2017-11-2
编辑:John D'Errico
2017-11-2
Eric - There are only two data points shown. This is to do interpolation in TWO independent variables. The point that is to be interpolated does NOT lie on the line between the two points, in (x,y).
So I will stand by my statement, that either that was made up data, or the problem is insolvable. Given the way it was stated by theintern, it seems quite clear they just picked 2 points. Whether they were the first two data points from a larger set is irrelevant. There is no interpolation possible here, not one that has any meaning.
plot([3.8 5],[.1 .7],'b-o',4.2 .4,'rx')
grid on
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186736/image.jpeg)
As you can see, the x does not lie along the line. So even if we decided the question was how to interpolate along that path, the x does not lie inside the convex hull of the data. So any interpolation here becomes an extrapolation, but there is NO information about the behavior of z in the direction orthogonal to the line. That means ANY prediction about an imputed value for z at the location marked by 'x' is completely arbitrary, because there are infinitely many equally valid solutions. ANY real (or even imaginary) value you wish to pose for z at that point is equally valid!
The point of my comments is that in order to answer this question as it is, we need to write a book, and a large one at that. It would need to cover the many varieties of interpolation methods. It would need to cover numerical analysis, computational geometry, etc.
Or, theintern can attach their real (or at least complete) data, as well as provide some more information as may be necessary, once we see the data. Without seeing that real data, all I can do is write a book, essentially to teach a complete semester long class about interpolation methods, and the infinitely many problems a person can have when just calling an arbitrary routine on a set of data that may not be appropriate for that routine. While I have taught such a class before, I certainly am not going to teach a complete class on Answers in the comments.
Eric
2017-11-2
@John: Thanks for the detailed response. Certainly, two data points is not nearly enough information to interpolate in this case, and I never claimed that it was. (As a visual person, I do appreciate the graphical proof though... nice touch.) In my original comment, I did not mean that the OP's data was not made up (it probably is), but rather that his/her data probably does not relate to reconstructing an analog signal from a digital signal, so my point was not going to be directly related to the question.
Rather, my point was to push back against Stephen's implication that all interpolated data is meaningless and to give an example for when interpolants might all be equally valid, but they are not all equally good, as you hinted at at the end of your first comment. In the case of signal reconstruction from sampled data, if you use a specific method of interpolation and fulfill various requirements, you will be guaranteed to reconstruct the original signal exactly as it was, without loss or error. In this case, the interpolated data would have perfect reliability and other methods of interpolation (e.g. linear) would be said to be less good. I admit this is a very specific case that does not apply here, but the case does exist and I wanted to point that out.
Having said that, I would say that one principle of the theorem I mentioned does apply and supports exactly what you are saying... The space over which the OP is interpolating is wildly undersampled. Unless it is known that the function is a straight line (unlikely), more data is needed to get any sort of meaningful interpolation out of the data.
John D'Errico
2017-11-2
I think what it comes down to is what I said originally. We cannot answer this intelligently without seeing the data in question. My reasoning is that far too often I see someone want to interpolate data that is not appropriate for any standard tool. I can give a LOT of examples on this. For example, suppose someone wants to interpolate data that lies on the surface of a sphere. As such, the function z(x,y) is multi-valued at most points in the (x,y) plane where the "function" is defined at all. This is a really common mistake that I see.
Or, I'll see people wanting to interpolate based on data that looks like this:
x = 0:10;
y = x.^1.5;
plot(x,y,'bo',4,9,'rx')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186742/image.jpeg)
Here, the red x probably lies within the convex hull of the data, and the data does not lie along a perfectly straight line. But any interpolation based on z values at those data points would be an insane thing to try. And yes, I've seen enough people asking to do just that on Answers, or in direct requests by mail. (For anyone who decides to send me direct mail to ask a question, PLEASE DON'T.)
Another common mistake is for someone to try to interpolate a function with a singularity. Interpolation methods hate singularities.
Another thing that people do wrong is to misunderstand what interpolation means. They think that just because an interpolation method claims to be smooth in some sense, that it can smooth out noise in their data.
I can go on and on with misunderstandings about interpolation that I have seen, but those are the most common ones.
So since we cannot know that theintern does not have one or more of these misunderstandings about interpolation, the only way to provide an intelligent answer is to see the data. At least then we would have a chance to provide advice without writing a book.
Stephen23
2017-11-3
编辑:Stephen23
2017-11-3
"my point was to push back against Stephen's implication that all interpolated data is meaningless and to give an example for when interpolants might all be equally valid,"
@Eric: "push back" against what exactly? We both wrote the same thing! Nowhere did I state that interpolated data is meaningless. I wrote that interpolation's usefulness is entirely dependent on having an understanding of the appropriateness of the interpolation method to the underlying physical model, and that there is no universal measure of "reliable".
"Certain conditions must be met in order to do this ... However, you must know some underlying information about your signal"
And now you agree with me!? First you state that my answer needs a "push back", and now you agree with my point? I am totally confused: was my comment wrong or not? We just wrote the same thing in two different ways: how does that require a "push back" ?
"Actually, interpolated data is not (always) "made-up" data. It does not appear that this is what the OP's data is, but interpolation is used all the time in signal processing to convert digital or sampled signals back to analog"
By definition interpolated data is made up data: interpolated data is data that did not exist before the interpolation. It may be, as both you and I stated in our different ways, that given particular data, knowledge of the physical model, and choice of interpolation method, that that "made up" data replicates a given signal.
I am totally confused about what needed a "push back".
theintern
2017-11-3
Hello friends, unfortunatelly I cannot share my datas. There are scattered 197x3 datas but I can't share them because of privacy policy. The datas are coming from a digitized contour plot.( x axis, y axis and heigth of contour,z. Thank you all for your replies.
Stephen23
2017-11-3
@theintern: if you cannot upload your actual data then you can upload some data that has similar features to the actual data, i.e. the same dimensions, the same basic relationship. It certainly would help us.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)