# 4d Interpolation of Table

조회 수: 14 (최근 30일)
River Vorse 2020년 11월 9일
답변: Raunak Gupta 2020년 11월 13일
I'm trying to interpolate a set of 4 variable data values in a table. Can I use interpn() for this?
the first column ranges (0:2:10)- full table not shown since there are hundreds of values. The first three columns are inputs such that at x =0, y= 16, z=40, there are a number of outputs shown in the right 7 columns. I'm trying to interpolate so that if I have a set of inputs x = 0.5, y = 16.7, z = 37.2, I can interpolate a value for one of the outputs in the right 7 columns.
##### 댓글 수: 2없음 표시없음 숨기기
River Vorse 2020년 11월 9일
My thought is :
x = data(:,1);
y = data(:,2);
z = data(:,3);
v = data(;,4);
xp = 0.5;
yp = 16.7;
zp = 37.2;
vp = interpn(x,y,z,v,xp,yp,zp)
River Vorse 2020년 11월 9일
this gives the following error

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

### 답변 (1개)

Raunak Gupta 2020년 11월 13일
Hi,
The error when using interpn is due to the data not being present in Grid format, meaning for every triplet of (x,y,z) in some range of x,y,z should have a value v also present. You can create the Grid format data for x,y,z using
[X1, X2, X3] = ndgrid(x,y,z);
But for the same you need to reshape the 4th column such that it represents corresponding values in X1, X2, X3. For this the length of unique x,y,z is required which gives the indices where values for learning interpolation are present.
You can see here about how the input array should look like.

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

### 카테고리

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