forked from sethupavan12/sample_project_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quadraticSolver.m
49 lines (34 loc) · 1.33 KB
/
quadraticSolver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function roots = quadraticSolver(a,b,c)
% quadraticSolver returns solutions to the
% quadratic equation a*x^2 + b*x + c = 0.
roots = zeros(1,2) %HAD TO SPECIFY THIS FOR CODER
if ~isa(a,'numeric') || ~isa(b,'numeric') || ~isa(c,'numeric')
error('quadraticSolver:InputMustBeNumeric', ...
'Coefficients must be numeric.');
end
roots(1) = (-b + sqrt(b^2 - 4*a*c))/ (2*a);
roots(2) = (-b - sqrt(b^2 - 4*a*c)) / (2*a);
end
function runAll() % Run all the functions in this class
x=1;
y=1;
lowRange = 2;
highRange = 50;
a = randi([lowRange highRange],x,y);
b = randi([lowRange highRange],x,y);
c = randi([lowRange highRange],x,y);
fprintf(" The roots for (%dx^2)+(%dx) +%d",a,b,c);
sheesh.quadraticSolver(a,b,c)
end
% This comment is added on experimental branch to test
% BUFFER
% function num = giveRandomNumber(x,y)
% %METHOD1 Summary of this method goes here
% % Detailed explanation goes here
% %need to find if MAX_SIZE is possible or not
% if ~isa(x,'numeric') || ~isa(y,'numeric')
% error('quadraticSolver:InputMustBeNumeric','Coefficients must be numeric.');
% end
% num = randi([2 1000000],x,y);
% %fprintf('Random Number is %d ',g);
% end