MATLAB: Using a vector to represent three coefficients.

vector

Hello I was hoping a could get a reality check on a simple code I wrote that was working the other day. I don't know if I'm just fat fingering something now or if it's bugged somewhere but I was able to input a vector and such as [1 2 3] and it would automatically replace [a b c].
function [quadRoots,disc] = Q1_19000046(coeff)
%[quadRoots,disc] = Q1_19000046(coeff);
%Compute quadRoots and disc of quadratic equation for parameters a, b, and
%c
coeff = [a b c];
X = sqrt(b .^2 - 4 .*a .*c);
Y = 2*a;
quadRoots = (-b + X) ./ Y;
disc = (-b - X) ./ Y;
end

Best Answer

function [quadRoots,disc] = Q1_19000046(coeff)
%[quadRoots,disc] = Q1_19000046(coeff);
%Compute quadRoots and disc of quadratic equation for parameters a, b, and
%c
a = coeff(1);
b = coeff(2);
c = coeff(3);
X = sqrt(b .^2 - 4 .*a .*c);
Y = 2*a;
quadRoots = (-b + X) ./ Y;
disc = (-b - X) ./ Y;
end