Question: Using Matlab, write a function called poly_val that is called like this p = poly_val(c0,c,x), where c0 and x are scalars, c is a vector,
Using Matlab, write a function called poly_val that is called like this p = poly_val(c0,c,x), where c0 and x are scalars, c is a vector, and p is a scalar. If c is an empty matrix, then p = c0. If c is a scalar, then p = c0 + c*x . Otherwise, p equals the polynomial, 0+1 +2 ++ , where N is the length of the vector c. Hint: you may want to use the .^ operator. Here are three example runs: >> format long
>> p = poly_val(-17,[],5000)
p = -17
>> p = poly_val(3.2,[3,-4,10],2.2)
p = 96.920000000000030
>> p = poly_val(1,[1,1,1,1],10)
p = 11111
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
