help-octave
[Top][All Lists]
Advanced

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

Re: Vectorizing interpolation?


From: Juan Pablo Carbajal
Subject: Re: Vectorizing interpolation?
Date: Wed, 10 Aug 2016 18:19:12 +0200

On Tue, Aug 9, 2016 at 9:03 PM, Nir Krakauer <address@hidden> wrote:
> Is it possible to vectorize something like the following loop?
>
> m = 1000; n = 30;
>
> A = sort (randn(m, n), 2);
>
> b = randn (m, 1);
>
> c = nan (m, 1);
>
> for i = 1:m
>
>   c(i) = interp1 (A(i, :), 1:n, b(i));
>
> endfor
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
>

It seems the difficulty lies on interp1 using only a single x-vector
(multiple y-vlaues would work). Can you invert the function to
interpolate? i.e. interp1 (1:n, A(i, :), zb(i))?
Otherwise I guess array/cellfun arte you only hope (or they parallel
implementations in the parallel pkg)



reply via email to

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