help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interpolating large table of data


From: Przemek Klosowski
Subject: Re: interpolating large table of data
Date: Mon, 23 Sep 2013 16:15:57 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

On 09/23/2013 12:39 PM, Dan McMahill wrote:
I'm  trying to do some data interpolation and feel like my code is getting really ugly and it seems there should be a nice clean way.  What I have is a multidimensional array:

vals(a,b,c,i)

a takes on values of either 1 or 2
b from 1-18
c from 0-63

and for each combination of a,b,c I need a vector of about 200 data points which represent the y values for a curve where all of my curves share the same x values.

so I should be able, for example do do

plot(xvals, vals(1,3,14))

and get one of the plots.

The catch is that I do not have data for some values of 'c' and in that case I need to fill in the missing data by interpolation.  So essentially what I have is a bunch of curves but some are missing.  The good news is that there is really no funny behavior.  Each data point in vals(1,3,14) should lie between the corresponding points in vals(1,3,13) and vals(1,3,15) and linear interpolation should be good enough.

This nice behavior only applies to keeping a and b constant and varying c.  If I don't have data for a=1 then there is no interpolating to get a=2 data and also if I don't have data for b=4 for example, I can't use other b data.

So, is there a clean way to do this?  I found myself headed down an extremely ugly path with lots of for loops and that just seems wrong.
I understand that you have an array like this one:     vals=zeros(2,18,64,200)
FIrst, the array indices start at zero, so if you could tolerate c=1:64 instead of 0:63 it could simplify things.
Next, if the missing a and b values are impossible to interpolate, do you need to include them? Could you simply
have a smaller ranges for them, i.e. b from 1 to 13 if b=3,5,8,10,12 are missing?

You could store NA (Not Available) in the array slice for the unavailable c:

vals(1,13,17,:)=NA

and then later find the NA values (isna(vals)) and use the indices to interpolate (or simply fill in the missing values as you are constructing the array).

vals(1,13,17,:)=mean([vals(1,13,16,:);vals(1,13,16,:)])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]