MATLAB: I cannot get the function to solve quadratic equations to work. Can anyone help

functionsquadratic equations

function [disc, quadRoots] = Q1_15024248(a,b,c);
disc = b^2-(4*a*c);
if disc < 0
disp('NaN')
elseif D==0
quadRoots = -b/2*a
else
x1 = -b + sqrt(disc)/(2*a);
x2 = -b - sqrt(disc)/(2*a);
quadRoots = [x1,x2];
end
end
it leaves me with the error message:
function [disc, quadRoots] = Q1_15024248(1,4,4);
Error: Function definitions are not permitted in this context.

Best Answer

Put your function code in a file called Q1_15024248.m somewhere on the MATLAB path (e.g., your working directory).