Cody

Problem 2163. Evaluate Polynomial

Solution 2863652

Submitted on 21 Aug 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
p = [1 0 -8 -7 5]; x = [ 5 7 9 ]; y_correct = [ 395 1965 5855]; assert(isequal(polynomial(p,x),y_correct))

Error using dot A and B must be same size. Error in polynomial (line 2) y = dot(p,x.^2); Error in Test1 (line 4) assert(isequal(polynomial(p,x),y_correct))

2   Fail
p = [1 0 -10 0 0 0 11 -50]; x = [3 7 4 5]; y_correct = [-260 655500 6138 46880] assert(isequal(polynomial(p,x),y_correct))

y_correct = -260 655500 6138 46880

Error using dot A and B must be same size. Error in polynomial (line 2) y = dot(p,x.^2); Error in Test2 (line 4) assert(isequal(polynomial(p,x),y_correct))

Suggested Problems

More from this Author4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!