Re: interpolation problem
- From: John D'Errico <woodchips@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 12:39:46 GMT
In article <ef12928.1@xxxxxxxxxxxxxxxx>,
"Catherine Noble" <cnoble@xxxxxxxx> wrote:
> interp is a matlab program. I believe you have to add in the "signal
> processing toolbox" and then you will have it. Lorenz is a
> handwritten program. I just want to interpolate a vector that I feed
> in and get out a smooth curve.
>
> Matlab's description of interp is:
>
> INTERP Resample data at a higher rate using lowpass interpolation.
> Y = INTERP(X,R) resamples the sequence in vector X at R times
> the original sample rate. The resulting resampled vector Y is
> R times longer, LENGTH(Y) = R*LENGTH(X).
>
> A symmetric filter, B, allows the original data to pass through
> unchanged and interpolates between so that the mean square error
> between them and their ideal values is minimized.
> Y = INTERP(X,R,L,CUTOFF) allows specification of arguments
> L and CUTOFF which otherwise default to 4 and .5 respectively.
> 2*L is the number of original sample values used to perform the
> interpolation. Ideally L should be less than or equal to 10.
> The length of B is 2*L*R+1. The signal is assumed to be band
> limited with cutoff frequency 0 < CUTOFF <= 1.0.
> [Y,B] = INTERP(X,R,L,CUTOFF) returns the coefficients of the
> interpolation filter B.
Its there all right. For some reason the search engine did
not find it when I looked on their site.
I still can't say what is wrong, and what discontinuities/
bumps you see, since I don't have that toolbox. Its possible
that resampling a Lorentzian using its choice of lowpass
filter suffers from the same problems that happen when a
polynomial is used to interpolate.
But you can smoothly resample a vector using a variety of
other methods. For example, inserting 15 elements smoothly
between each element in vec just takes this:
vec = 1./((-10:10).^2+1);
n = length(vec);
m = 16;
vecr = interp1(1:n,vec,linspace(1,n,1+(n-1)*m),'spline');
Or you may prefer to use pchip in interp1:
vecr = interp1(1:n,vec,linspace(1,n,1+(n-1)*m),'pchip');
Or, if you want to download my inpaint_nans from Matlab
central, this will work:
vecr = [vec;zeros(m-1,n)+nan];
vecr = inpaint_nans(vecr(1:(1+m*(n-1))));
HTH,
John D'Errico
--
The best material model of a cat is another, or
preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
.
- References:
- interpolation problem
- From: Catherine Noble
- Re: interpolation problem
- From: John D'Errico
- Re: interpolation problem
- From: Catherine Noble
- interpolation problem
- Prev by Date: Re: licence plate recognition
- Next by Date: Re: Most frequent element in array
- Previous by thread: Re: interpolation problem
- Next by thread: using memmapfile()
- Index(es):