0
0
MATLABdata~10 mins

Polynomial evaluation and roots in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to evaluate the polynomial p at x = 2.

MATLAB
p = [1 -3 2];
y = polyval(p, [1]);
Drag options to blanks, or click blank then click option'
A2
B3
Cx
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name instead of a number.
Forgetting to pass the evaluation point as the second argument.
2fill in blank
medium

Complete the code to find the roots of the polynomial p.

MATLAB
p = [1 -3 2];
r = [1](p);
Drag options to blanks, or click blank then click option'
Apolyval
Broots
Csolve
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using polyval instead of roots.
Using find which is for arrays, not polynomials.
3fill in blank
hard

Fix the error in the code to correctly evaluate the polynomial p at x = 5.

MATLAB
p = [2 0 -1 3];
y = polyval([1], 5);
Drag options to blanks, or click blank then click option'
Ap
Bpolyval
C[2 0 -1 3]
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the arguments of polyval.
Passing the number as the first argument.
4fill in blank
hard

Fill both blanks to create a polynomial vector for p(x) = 3x^2 - 4x + 1 and evaluate it at x = 3.

MATLAB
p = [[1] [2] 1];
y = polyval(p, 3);
Drag options to blanks, or click blank then click option'
A3
B-4
C4
D-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive 4 instead of -4.
Swapping the order of coefficients.
5fill in blank
hard

Fill all three blanks to create a polynomial vector for p(x) = x^3 - 6x^2 + 11x - 6 and find its roots.

MATLAB
p = [[1] [2] [3] -6];
r = roots(p);
Drag options to blanks, or click blank then click option'
A1
B-6
C11
D6
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive 6 instead of -6.
Mixing up the order of coefficients.