What will be the output for the below block of code? [code] P=[1 3 2]; r=roots(P); [/code]

Khang Lê

New member
What will be the output for the below block of code?
Code:
	P=[1 3 2]; r=roots(P);
A. r=[-2,-2]
B. r=[-2 -1]
C. There is an error in the code
D.
r = -2
-1
 
Answer: d
Explanation: The function roots(p) generate a column vector, and not a row vector, containing the roots of a polynomial. So option a and b cannot be the answer and there is no error in the code. The answer is option d.
Output:
r = -2
-1
 

Tìm kiếm

Back
Top