4D interpolation

Ben Abbott bpabbott at mac.com
Tue May 27 06:11:41 CDT 2008


On May 26, 2008, at 3:31 AM, thanatos187 wrote:

>
> Ben Abbott wrote:
>>
>> On May 20, 2008, at 3:52 AM, thanatos187 wrote:
>>
>>>
>>> Hi
>>> I want to interpolate my values with the spline method. I did it
>>> with the
>>> command:
>>> vi = interpn(u,v,w,x,z,uu,vv,ww,xx,'spline');
>>> where u,v,w,x are vectors of the same length defining the point with
>>> the
>>> value z. uu,vv,ww,xx are creaed by the ndgrid command. i got the  
>>> error
>>> message: "wrong number or incorrectly formatted input argument".
>>>
>>> thanks for any help
>>> Thanatos
>>
>> Can you post a simple example? Does the problem occur for "nearest",
>> "linear", or "cubic" interpolation?
>>
>> Ben
>>
>> It occurs for all methods. I want to use a spline interpolation. I  
>> have
>> 1500 data points, so the length of the colum vectors are 1500.
>> uu,vv,ww,xx, are matrixes of the size (10  10  10  10)
>>
>> thanatos

I tried a 3D and 4D example.

clear all

v1 = 0:0.2:2;
v2 = v1;
v3 = v1;
[x1,x2,x3] = ndgrid(v1,v2,v3);
y = (x1.*x2 + x1.*x2.^2).*x3;
z = interpn(x1,x2,x3,y,v1,v2,v3,'linear')

v4 = v1;
[x1,x2,x3,x4] = ndgrid(v1,v2,v3,v4);
y = (x1.*x2 + x1.*x2.^2).*x3./(1+x4);
z = interpn(x1,x2,x3,x4,y,v1,v2,v3,v4,'linear')

Both of these work for me. Please verify they work for you as well.

Ben



More information about the Help-octave mailing list