find the root of a second order polynomial in matlab

To find the roots of a second order polynomial in MATLAB, you can use the roots function. The roots function takes a vector of polynomial coefficients as an input and returns the roots of the polynomial as a column vector.

Here is an example:

main.m
% define the polynomial coefficients
a = 1;
b = 4;
c = 3;

% find the roots
r = roots([a b c]);

% display the roots
disp(r);
126 chars
11 lines

In this example, the polynomial is ax^2 + bx + c = 0, where a = 1, b = 4, and c = 3. The roots function is called with the vector [a b c] as an input. The function returns the roots of the polynomial, which are displayed using the disp function.

gistlibby LogSnag