Bird
0
0

You have a polynomial p = [1 -6 11 -6] representing x^3 - 6x^2 + 11x - 6. Which MATLAB code correctly finds the roots and evaluates the polynomial at x = 2?

hard📝 Application Q15 of 15
MATLAB - Numerical Methods
You have a polynomial p = [1 -6 11 -6] representing x^3 - 6x^2 + 11x - 6. Which MATLAB code correctly finds the roots and evaluates the polynomial at x = 2?
A<code>r = roots(p); y = polyval(p, 2);</code>
B<code>r = polyval(p, 2); y = roots(p);</code>
C<code>r = roots(2); y = polyval(p);</code>
D<code>r = roots(p, 2); y = polyval(p, 2);</code>
Step-by-Step Solution
Solution:
  1. Step 1: Find roots of polynomial

    Use roots(p) to get zeros of polynomial p.
  2. Step 2: Evaluate polynomial at x=2

    Use polyval(p, 2) to find polynomial value at 2.
  3. Final Answer:

    r = roots(p); y = polyval(p, 2); -> Option A
  4. Quick Check:

    roots(p) finds zeros, polyval(p,x) evaluates [OK]
Quick Trick: roots() finds zeros; polyval() evaluates at points [OK]
Common Mistakes:
  • Swapping roots and polyval calls
  • Passing wrong arguments to roots
  • Using roots with two arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes