Interpolate by taking the highest point

6 visualizzazioni (ultimi 30 giorni)
MMer
MMer il 8 Set 2016
Modificato: MMer il 8 Set 2016
Hi everyone,
Does someone know how to interpolate by taking the value of the highest point in vicinity (instead of making linear or cubic interpolation of the points in vicinity, or taking the nearest one).
Interp2 doesn't have any kind of method to do that.
I guess I could copy the "interp2" function and modify it, but I don't really know what I have to change. I would have to put a "take the max of those four nearest points" somewhere but I can't understand clearly how this function was written.
Moreover, I said four points but I would like it to take the highest value of multiple points (not only the four nearest points or so but the 16 nearest or more)
I searched on file exchange to see if there was any function like that but couldn't find anything.
Does someone have any sort of starting point on how to do that ?
To detail further :
I have a list of points where I want to know the elevation. I have a matrix with points where the elevation is known.
By interpolating, I get the elevation for the points I want to know. But it's computated by linear method.
I lose some data because the points on the new grid are more widely spaced. (I need only those precise points for further computations) In order to make up for that, when I compute the value of one of the point I'm interested in, I want to take the value of the (known) point which has the highest elevation, in a certain radius (which will be defined depending on how spaced are the known points and how spaced are the new points, in order to take all the known ones into account. If it simplify things, let's say I want to use the 16 nearest points)
I need the highest elevation because it is the worst case for other computations.
Forget about taking multiple points into account, it's "just" about applying 'highest in vicinity' instead of 'nearest' or 'linear' in a 2D interpolation.

Risposte (2)

goerk
goerk il 8 Set 2016
Since R2016a there is the function: movmax
  1 Commento
MMer
MMer il 8 Set 2016
Great function indeed but it only works in 1D and can't be used for interpolation (only compute the maximum for a given number of points, consecutively, not for a given number of points around points we want (which could be anywhere))
But maybe if I get my hands on the code for that function, it can give me some inspiration ^^
However I have to work on R2009b computers
Thanks for the tip anyway !

Accedi per commentare.


John D'Errico
John D'Errico il 8 Set 2016
Modificato: John D'Errico il 8 Set 2016
You need to CLEARLY define what you mean. So far, you have said that you want to use the highest point. But there is only one highest point in any list of points, unless there are multiple values that are exactly the same. And in that case, who cares where it came from, since they all have the same value? And you have not limited it to how far away any candidate point would be for you to use it.
So what you have said so far makes no sense in context of interpolation. It reduces to simply using the global maximum value from any of your data points.
Unless you can be clear about what you want, it is impossible to define a computer code that will do what you have no idea of what it is that you want to do. Computers are not magical things, that can divine what it is you want to do without your even knowing it yourself. Ok, maybe if Harry Potter has a computer, it can do that. But for the rest of us...
For example, maybe you are asking to find the maximum value within some fixed radius of any given location in space. In that case, given a location and some fixed radius, just find all points from your set that lie within that radius, and take the maximum at those points. WTP?
IF your points all lie on a regular lattice, then you MIGHT be able to use the function movmax. I'm not at all sure of that, since you have not clearly stated what you need.
  1 Commento
MMer
MMer il 8 Set 2016
"For example, maybe you are asking to find the maximum value within some fixed radius of any given location in space. In that case, given a location and some fixed radius, just find all points from your set that lie within that radius, and take the maximum at those points."
Well, it's exactly that.
I have a list of points where I want to know the elevation. I have a matrix with points where the elevation is known.
By interpolating, I get the elevation for the points I want to know. But it's computated by linear method.
I lose some data because the points on the new grid are more widely spaced. (I need only those precise points for further computations) In order to make up for that, when I compute the value of one of the point I'm interested in, I want to take the value of the (known) point which has the highest elevation, in a certain radius (which will be defined depending on how spaced are the known points and how spaced are the new points, in order to take all the known ones into account. If it simplify things, let's say I want to use the 16 nearest points)
I need the highest elevation because it is the worst case for other computations.
Forget about taking multiple points into account, it's "just" about applying 'highest in vicinity' instead of 'nearest' or 'linear' in a 2D interpolation.
If it's still not clear enough, I can explain further.
Sorry for not being clear the first time.

Accedi per commentare.

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by