Create a vector form a polynomial evaluation

2 次查看(过去 30 天)
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

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-11-17
编辑:Andrei Bobrov 2012-11-17
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 个)

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by