USING MATLAB
Write a program called QuadProg that determines the roots of a quadratic equation. Use functions to implement each action. Zip you directory of *.m files into a single file and turn this in on BBLearn under Class Activities.
QuadProg
displayResults should have two inputs: displayResults(string, value);
max_of_two=getLargerOfTwo(A,B);
str1='max of A and B is';
displayResults(str1,max_of_two);
isEven/isOdd
Write these two functions that determine if the inputs to the QuadProg are even or odd.
Now update the QuadProg program to report:
getLargerOfTwo
Write a function that gets 3 inputs and then finds the max of two numbers and reuse the same function to get the max of 3 numbers. Put this code below the Quadratic code.
:: Solution ::
function inpvalue = getInput()
inpvalue = input("Please enter value:");
end
function discriminant = getDiscriminant(a,b,c)
discriminant = b*b - (4*a*c);
end
function Denominator = findDenominator(a)
Denominator = 2*a;
end
function [root1,root2] = findRoot(Denominator,discriminant,b)
root1 = -1*b + sqrt(discriminant);
root1 = root1/Denominator;
root2 = -1*b - sqrt(discriminant);
root2 = root2/Denominator;
end
function displayResults()
a = getInput();
b = getInput();
c = getinput();
discriminant = getDiscriminant(a,b,c);
Denominator = findDenominator(a);
root1,root2 = findRoot(Denominator,discriminant,b);
disp(root1);
disp(root2);
if(root1 > root2)
disp(root1)
else
disp(root2)
end
end
Please rate my answer.Thank
you...
Get Answers For Free
Most questions answered within 1 hours.