MATLAB: Help with quadriatic formula

qadratic solver

Hi everyone,
We are to create a function using the editor to solve a quadratic formula. The hard part is the user is to be able to input just the equation ie: Ax^2+Bx+C=0 (not the values of ABC). (Below is what I have so far)
____***_*%The user input the formula they want solved_____
function [xpos, xneg] = Roots(equation)
%Quadratic equation format is = Ax^2 + Bx + C = 0
A = strtok(equation, 'x');
B =
C =
%This is the discriminant
D = B .^2 - 4 .* A .* C;
%These are the equation to find the positive and negative values of x
xpos = (-B + sqrt(D)) ./ (2 .* A)
xneg = (-B - sqrt(D)) ./ (2 .* A)
end

Best Answer

You showed enough I'll do more than normally would on first response...
s=inputdlg('Enter quadratic: ','Quadratic Solver Input',1,{'ax^2+bx+c'});