Link to home
Start Free TrialLog in
Avatar of crichtx
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)
Avatar of yuk99
yuk99
Flag of United States of America image

So, what is your question?
Avatar of crichtx
crichtx

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.
Avatar of crichtx

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;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crichtx

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.