Create a vector form a polynomial evaluation
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I have a polynomials coefficients matrix of W rows in the form f(x)= ax^2 + bx + c
M= [a1 b1 c1 ; a2 b2 c2 ; ... ... ...];
and a column-vector of x
X=[
x1
x2
x3
x4
x5
x6
x7
]
I solve in this way:
y1M1 = polyval(M ( 1 , : ), X(1,:) );
y2M2 = polyval(M ( 2 , : ), X(2,:) );
y3M3 = polyval(M ( 3 , : ), X(3,:) );
...
...
...
example: M1 -> M(1,:) -> (a1 * (x1)^2) + (b1 * x1) + c1
Is possible a combination of commands to obtain a single vector with all the y ?
If I'm not clear, please ask me... thanks
0 Commenti
Risposta accettata
Andrei Bobrov
il 17 Nov 2012
Modificato: Andrei Bobrov
il 17 Nov 2012
y = cellfun(@(x,y)polyval(x,y),num2cell(M,2),num2cell(X));
or
y = arrayfun(@(n)polyval(M(n,:),X(n)),(1:numel(X))');
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Polynomials in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!