MATLAB: Create a vector form a polynomial evaluation

vector . polynomial .

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

Best Answer

y = cellfun(@(x,y)polyval(x,y),num2cell(M,2),num2cell(X));
or
y = arrayfun(@(n)polyval(M(n,:),X(n)),(1:numel(X))');