Borrar filtros
Borrar filtros

Create a vector form a polynomial evaluation

3 visualizaciones (últimos 30 días)
Max
Max el 17 de Nov. de 2012
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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 17 de Nov. de 2012
Editada: Andrei Bobrov el 17 de Nov. de 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))');

Más respuestas (0)

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by