3
$\begingroup$

I have a (long, >50K elements) unstructured list with a header similar to;

AList[[1]] = {x,y,z,var1,var2,var3,var4,...,varN}

I want to interpolate z, var1, var2, ... , varN over x,y. IE. var1 dependent on x and y but not z, Is there an efficient way to do this?

Currently I've got a table with a separate interpolate for each variable which takes a `long' time to compute.

Table[
    InterZ = Interpolation[{#[[1]],#[[2]],#[[3]]} &/@ AList, InterpolationOrder -> 1];
    InterVar1 = Interpolation[{#[[1]],#[[2]],#[4]]} &/@ AList, InterpolationOrder -> 1];
    InterVar2 = Interpolation[{#[[1]],#[[2]],#[5]]} &/@ AList, InterpolationOrder -> 1];
    ....
    InterVarN = Interpolation[{#[[1]],#[[2]],#[N+3]]} &/@ AList, InterpolationOrder -> 1];
];

Is there a better solution?

Thanks for any input

$\endgroup$
4
$\begingroup$

I would probably write this

Interpolation[AList[[All, {1, 2, #}]], InterpolationOrder -> 1] & /@ Range[3, maxN + 3]

It's probably a little bit faster than what you have. BTW it looks in your example as if the header is not actually a part of AList, if it is you should remove it using Rest, i.e. Rest[Alist][[All...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.