Matlab - interp1 (linear/nearest)

Hi,

Was wondering if anyone knows why when interpolate the following data (which is part of a larger matrix of data 14x22) that the NaN values remain:

x = [0.4500; 0.6300; 0.9700; 2.2500; 4.4700; NaN; 2.4700; 3.2400; 5.5600; 6.1300; 6.5600; 6.9900; 7.3500; 7.6300; 7.7700]

y = [0; 2.3469; 26.3453; 50.3483; 74.3486; 98.3481; 122.3492; 146.3461; 170.3467; 194.3469; 218.3486; 242.3467; 266.3469; 290.3500; 307.4056]

t = [0; 24; 48; 72; 96; 120; 144; 168; 192; 216; 240; 264; 288; 312]

z = interp1(x,y,t)

But z is returned with NaNs. Using 'spline' removes the NaN but then this "over smooths" the data.

Is there a way to interpolate between the NaN values?

Thanks

Re: Matlab - interp1 (linear/nearest)

"NaN" is short for "not a number".Typically it shows up in numeric calculations where the computed value would be too large to fit in the computer or calculator. It can be thought of as meaning "infinite" as, for example, 1 divided by a very very small number produces a huge quotient: 1/x, as x goes to 0, goes to infinity.

Re: Matlab - interp1 (linear/nearest)

Thanks for the reply. I understand that the NaN is not a number. This was data imported from excel and I thought interp1 could be used to interpolate between the NaN in the data to infill the missing data.

Re: Matlab - interp1 (linear/nearest)

these concept is very helpful for me thanks to all

all the best

Re: Matlab - interp1 (linear/nearest)

Quote:

Originally Posted by

**rem88** Thanks for the reply. I understand that the NaN is not a number. This was data imported from excel and I thought interp1 could be used to interpolate between the NaN in the data to infill the missing data.

Since NaN does not distinguish between +/- large and out of valid range for a double you cannot do any kind of fudged interpolation between a double and a NaN.

Also if the NaN corresponds to a singularity the function may well change sign there and you would never know ...

.