How to back interpolation to find x from z and y?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ercan duzgun
le 15 Fév 2017
Commenté : ercan duzgun
le 15 Août 2019
I would like to do "back" interpolation to find an x value from the given values of z and y. (2Dimensional x,y,z matrix table is available). Is there any prepared MATLAB function for it?/ And how to do it in Simulink(Lookup Table Dynamic block is for 1D. I need 2D)?
As an example: x =[01 2 3 4 5]; y=[ 30 40 50 60]
z=[
1 2 3 4 5
3 4 5 6 7
5 6 7 8 10
7 8 10 10 13]
Table=
1 2 3 4 5
---------------
30 ! 1 2 3 4 5
40 ! 3 4 5 6 7
50 ! 5 6 7 8 10
60 ! 7 8 10 10 13
According to this given values, I would like to find the x value for a given data of y=43, and z=6.8
Thanks in advance.
Plus de réponses (2)
John D'Errico
le 15 Fév 2017
Is there something already written in MATLAB to do this? No. Given that your problem is not terribly common, it would be unexpected if it was already written.
Is it possible to do? Yes. Not even that terribly difficult.
You have an array that essentially defines the relation z(x,y).
1. Use interp2 to interpolate the array along the line y = 43, so for each value of x, determine z at the given y value. The result will be a vector of z values, one for each location in x.
2. Find any pairs of locations that cross the desired z level.
3. Interpolate linearly to find x that yields the given z level exactly. (Well, exactly to within the accuracy of linear interpolation.)
Phillip Resor
le 14 Août 2019
x = [1,2,3,4,5];
y = [30,40,50,60];
[X, Y] = ndgrid(x,y);
Z = [1,2,3,4,5;3,4,5,6,7;5,6,7,8,10;7,8,10,10,13]'; % transpose to match ndgrid
yp = 43;
zp = 6.8;
F = griddedInterpolant(X, Y, Z);
fun = @(xp)F(xp,yp)-zp;
xp = fzero(fun,mean(x))
And checking:
F(xp,yp)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!