필터 지우기
필터 지우기

Create a vector form a polynomial evaluation

조회 수: 3 (최근 30일)
Max
Max 2012년 11월 17일
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