3D look up interp3

12 Ansichten (letzte 30 Tage)
Sivateja Maturu
Sivateja Maturu am 9 Apr. 2019
Bearbeitet: Gabriel Felix am 28 Apr. 2021
May I know, I have a problem with 3D lookup table. I have 16x40x3 table, all populated. But the values ​​I want to have 16x79x9 values ​​which all exists in the limits. And I am using interp3 (x, y, z, V, x ', y', z '). And the sizes are
x: 16 valued array
y: 40 valued array
z: 3 valued array
V: 16x40x3 matrix
x ', y', z 'are scalars
May I know what is wrong here? I find the error.
Error using gridded Interpolant
The grid vectors do not define a grid of points that matches the given values.
Please help

Antworten (2)

David Wilson
David Wilson am 9 Apr. 2019
You don't give us much to work on, so I'll make up some data that follow your dimensions.
x = linspace(-1,1,16); y =linspace(-1,1,40); z = linspace(-1,1,3);
[X,Y,Z] = meshgrid(x,y,z);
V = sin(X)+cos(Y)+Z.^2; % some function
This generates a data cube in the dimensions you said (16*40*3). I've made up a well behaved function (since I had nothing to go on.)
Now we will generate an interpolating grid cube of the dimensions you wanted (16*79*9) using meshgrid.
xi = linspace(-0.5,1,16); yi = linspace(-0.8,0.8,79); zi = linspace(-1,1,9);
[Xi,Yi,Zi] = meshgrid(xi,yi,zi);
Now we are ready to interpolate in 3D.
Vi = interp3(X,Y,Z,V, ...
Xi, Yi, Zi)
The variable Vi is your interpolated output.
>> size(Vi)
ans =
79 16 9
  1 Kommentar
Sivateja Maturu
Sivateja Maturu am 9 Apr. 2019
In my case I am looking for a interpolation of scalars. I mean,xi, yi,zi are scalrs in my case which are within limits of x,y,z

Melden Sie sich an, um zu kommentieren.


David Wilson
David Wilson am 9 Apr. 2019
In that case it's easy, just use them as the interpolated input: say zt x=0.5, y=0.7,z=-0.3
Vi = interp3(X,Y,Z,V, ...
0.5, 0.7, -0.3)
  1 Kommentar
Gabriel Felix
Gabriel Felix am 28 Apr. 2021
Bearbeitet: Gabriel Felix am 28 Apr. 2021
interp3(X,Y,Z,V,Xq,Yq,Zq):
- X is the variable that contains the base values of the columns of V.
- Y is the variable that contains the base values of the rows of V.
- Z is the variable that contains the base values of the 3rd dimension of V
The names of variables X, Y and Z further confuses us, because they dont mean the literal vectors X, Y and Z. They express the reference values for:
X: Columns - disposed on the rows
Y: Rows - disposed on the columns
Z: 3rd dimension - disposed on the 3rd dimension
Ex.
V = [1 2 3 4 5 ;
6 7 8 9 10]
sizeX = 5 -> 5 columns
sizeY = 2 -> 2 rows
sizeZ = 1 -> 1 3rd dim
interp3(V,5,2,1) = 10
Ex.
V(:,:,1) = [
1 2 3 4
5 6 7 8
9 10 11 12]
V(:,:,1) = [
13 14 15 16
17 18 19 20
21 22 23 24]
sizeX = 4 -> 4 columns
sizeY = 3 -> 3 rows
sizeZ = 2 -> 2 3rd dim
interp3(V,3,3,2) = 19
Obs.: I didnt use the X,Y,Z values because I would have to create them and it would take long
The same applies to interp2

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by