crichtx
asked on
Polynomial function
a MATLAB function polyn( a,x ) that accepts two arguments. The first is a vector of polynomial coefficients, ai such that a1 is the coefficient of the highest power of x in the polynomial
p(x)=a1xn-1 +a2xn-2 +¿+an-1x+an
The argument x in the function is a value of x at which the polynomial is to be evaluated. The return value of the function is the value of the function evaluated at x. Once written test your function with the following:
a. y=polyn([3421],0.5) b. y=polyn([232015],1) c. y=polyn([1;0;-2;3;0;1],2)
p(x)=a1xn-1 +a2xn-2 +¿+an-1x+an
The argument x in the function is a value of x at which the polynomial is to be evaluated. The return value of the function is the value of the function evaluated at x. Once written test your function with the following:
a. y=polyn([3421],0.5) b. y=polyn([232015],1) c. y=polyn([1;0;-2;3;0;1],2)
So, what is your question?
ASKER
How do I write a matlab function to satisfy the conditions given?
It looks like a homework. We cannot give you ready-to-use solution, but surely can help to complete it. You have almost everything. Try to put it together to a function. Ask here if you have a specific problem.
ASKER
what about this?
function out=polyn(a,x)
p=0;
fin=length(a);
for i=1:fin
p=p+a(i)*x^(fin-i);
end
out=p;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I greatly appreciate the clarification and the challenge, keep up the good work; however this is not homework, just a new skill I felt the need to acquire.