help-octave
[Top][All Lists]
Advanced

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

Re: Interpolation problem


From: Martin Helm
Subject: Re: Interpolation problem
Date: Sat, 24 Mar 2012 03:19:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0

Am 24.03.2012 03:02, schrieb Terry Duell:
> Hullo All,
> I have a vector (y, 1012 elements) which has many zeros, in fact all
> but 24 of the values are zero.
> I would like to use the non zero values to interpolate values for the
> zero elements.
> I have used 'find' to locate the non zeros, but haven't been able to
> generate the intervening interpolated values, as I would like.
> Here is what I have tried.
>
> Ynz = find(y);
> Yy = interp1(x,y,Ynz,'linear');
>
> The vector x has size 1 1012,  and is the abcissa values of Y.
> Y is the ordinate values and has size 1 1012, and Ynz (the nonzeros in
> y) has size 1 24.
> Yy, the result of the interpolation has size 1 24.
>
> What I want is a Yy, size 1 1012, which relates to my x and y, with
> all possible zeros interpolated from the non zero values in y.
>
> Clearly, I have a misunderstanding of how 'interp1' is to be used. I
> have tried a few variations in an attempt to better understand how to
> get my required result, but it always returns Gy with size 1 24.
>
> Is there a way of achieving my desired result?
>
> Cheers,
I think you want
Xnz = find(y);
Yy = interp1(Xnz, y(Xnz), 1:1012, 'linear')

find gives you back the index values of the non zero elements, y(Xnz)
gives you the corresponding values and you want to interpolate on the
index set of a 1012 elements vector which is the finite sequence 1:1012.



reply via email to

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