|
From: | Thomas D. Dean |
Subject: | Re: Apply Polyval to Array |
Date: | Sun, 12 Jun 2016 20:58:22 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
On 06/12/2016 08:25 PM, Doug Stewart wrote:
On Sun, Jun 12, 2016 at 10:03 PM, Thomas D. Dean <address@hidden <mailto:address@hidden>> wrote: I want to vectorize this: p1 = [1,2,3;4,5,6;7,8,9]; for idx=1:3 polyval(p1(idx,:),0) endfor cellfun("polyval",{p1},{[0;0;0]}); ## fails arrayfun("polyval",p1,0 "UniformOutput",false)); ## wrong arrayfun("polyval",p1,zeros(3,3), "UniformOutput",false); ## wrong Tom Dean _______________________________________________ Help-octave mailing list address@hidden <mailto:address@hidden> https://lists.gnu.org/mailman/listinfo/help-octave does this help p1 = [1,2,3;4,5,6;7,8,9]; t=[1 2 3] f=@(t) polyval(p1(t,:),0) arrayfun(f,t) --
My initial polynomials are (3,14) octave:693> p1 p1 = Columns 1 through 6: 2.3055e+06 2.3055e+06 2.3056e+06 2.3056e+06 2.3056e+06 2.3056e+06 2.3059e+06 2.3060e+06 2.3060e+06 2.3060e+06 2.3061e+06 2.3061e+06 2.3064e+06 2.3064e+06 2.3064e+06 2.3065e+06 2.3065e+06 2.3065e+06 Columns 7 through 12: 2.3057e+06 2.3057e+06 2.3057e+06 2.3058e+06 2.3058e+06 2.3058e+06 2.3061e+06 2.3062e+06 2.3062e+06 2.3062e+06 2.3063e+06 2.3063e+06 2.3066e+06 2.3066e+06 2.3066e+06 2.3067e+06 2.3067e+06 2.3067e+06 Columns 13 and 14: 2.3059e+06 2.3059e+06 2.3063e+06 2.3064e+06 2.3068e+06 2.3068e+06These are the coefficients of the Chebyshev polynomials from the JPL DE405. I need to evaluate them at several points. And, I will be doing this in a loop.
v = an array of values, in the range 0..1 x=polyval(p1(1,:),v(1)) y=polyval(p1(2,:),v(1)) z=polyval(p1(3,:),v(1)) Tom Dean
[Prev in Thread] | Current Thread | [Next in Thread] |