AW: 4D interpolation
Ben Abbott
bpabbott at mac.com
Tue May 27 07:46:42 CDT 2008
On Tuesday, May 27, 2008, at 07:35AM, "Hofstaetter, Michael: Mr.: (external)" <michael.hofstaetter.external at epcos.com> wrote:
>-----Ursprüngliche Nachricht-----
>Von: Ben Abbott [mailto:bpabbott at mac.com]
>Gesendet: Dienstag, 27. Mai 2008 13:12
>An: Hofstaetter, Michael: Mr.: (external)
>Cc: help-octave at octave.org
>Betreff: Re: 4D interpolation
>
>
>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
>
>
>Hi Ben
>
>Your examples also work for me, but i have the problem that my data coordinates are not equidistant in any direction. The coordinates are randomly generated. Additionally are the points not sorted, but this is not a problem. Probably i have to write a new function.
>
>Thanatos
>
Hi Thanatos,
Having non-equidistant points should not be a problem.
You can verify this by calculating v1 as
v1 =unique(2*rand([1,10]));
and using the same examples as before.
The "unique" function is used in the unlikely event that duplicates exist, and to make sure the values are sorted.
You'll need to make sure your values are sorted, but this should not produce the error you see.
Regarding your error, can you check the size of your variables corresponding to x1, x2, x3, x4 and y?
octave:22> whos x1 x2 x2 x4 y
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
x1 10x10x10x10 80000 double
x2 10x10x10x10 80000 double
x2 10x10x10x10 80000 double
x4 10x10x10x10 80000 double
y 10x10x10x10 80000 double
Total is 50000 elements using 400000 bytes
You can place this command in your own script and verify that the inputs are all correct. When I first tried my example I did not calculate y correctly and encountered the same error as you.
Ben
More information about the Help-octave
mailing list