Question

USING MATLAB Write a program called QuadProg that determines the roots of a quadratic equation. Use...

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

  • write a function called getInputs to get a single input value.
  • write a function called findDiscriminant
  • write a function called findDenominator
  • write a function called findRoot
    • which will be used for both roots
  • write a function called displayResults

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.

  • write a function called isEven
  • write a function called isOdd
  • Reuse displayResults to show the results.

Now update the QuadProg program to report:

  • has no roots - imaginary
  • has one root
  • has two roots
  • Reuse displayResults to show the results.

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.

  • reuse getInputs to get 3 values.
  • write a function getLargerOfTwo
  • Then use the same function getLargerOfTwo to create a getLargestOfThree function
  • Reuse displayResults to show the results.

Homework Answers

Answer #1

:: 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...

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The roots (solutions) to the quadratic equation ax2 +bx+c = 0 is given by the well-known...
The roots (solutions) to the quadratic equation ax2 +bx+c = 0 is given by the well-known formula x = 2a −b ± √b −4ac 2 Write a python program that takes the three coefficients a, b, and c as input, computes and displays the solutions according to the aforementioned formula. Note the ± in the numerator means there are two answers. But this will not apply if a is zero, so that condition must be checked separately; design your program...
Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as...
Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as follows: a) D =0; the equation has a double solution.      x1 = x2 = -b/2a b) D>0; the question has two different solutions x1 and x2.      x1= (-b-sqrt(D))/2a      x2= (-b+sqrt(D))/2a c) if D<0; the equation has no real solution
Description: You will be creating a program extractIP.py which will read from a file called wireShark.txt...
Description: You will be creating a program extractIP.py which will read from a file called wireShark.txt and extract all the ip addresses which can be of the format: 1,2 or 3 digits. 1, 2 or 3 digits.1, 2, or 3 digits. 1,2,3 digits Here are some examples of valid IPv4 addresses: 10.0.0.1, 12.123.123.123, 126.255.255.254, 191.255.255.254, 192.168.1.1, 239.255.255.255 And you will output them to another file called IPAddresses.txt , one per line, listing source and destination. Example: Source Destination 12.123.123.123 123.123.123.123...
Program Instructions Write a program called censor.py. This program will have the following functionality and requirements:...
Program Instructions Write a program called censor.py. This program will have the following functionality and requirements: Has a main function: That asks the user to input a sentence Then asks the user to enter a list of words they want to replace (separated by spaces) Calls a function called replaceMultiWords passing those two parameters, which returns a filtered string Prints out the filtered (censored) string to the console Has a replaceMultiWords function that: Takes a string "sentence" and a string...
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
using matlab please present code for the following (ALL PARTS PLEASE AND THANK YOU) 1. No...
using matlab please present code for the following (ALL PARTS PLEASE AND THANK YOU) 1. No Input/No Output Write a function that has no input and no outputs. This function will simply display some text when it is called. (this is my code, are there suggestions for improvements?) function Display() disp('some text') end 2. 1 Input/No Outputs Write a function with one input and no outputs. This function will simply display a variable that is provided as an input argument....
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
● Write code to read the content of the text file input.txt using JAVA. For each...
● Write code to read the content of the text file input.txt using JAVA. For each line in input.txt, write a new line in the new text file output.txt that computes the answer to some operation on a list of numbers. ● If the input.txt has the following: Min: 1,2,3,5,6 Max: 1,2,3,5,6 Avg: 1,2,3,5,6 Your program should generate output.txt as follows: The min of [1, 2, 3, 5, 6] is 1. The max of [1, 2, 3, 5, 6] is...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half of the code but I am using else and if statements. I feel like the code is too long to do a simple calculation. In CodeBlock when you build and run your code, a new terminal window opens (in windows a new console window) and you can enter your inputs there. It is not like eclipse that you enter your inputs in console view....