Question

In: Computer Science

MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...

MATLAB: Write as a script in the editor window of matlab.

  1. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):

Solutions

Expert Solution


%   MATLAB Function to solve the root of a quadratic equation

function [z1, z2] = GetRoot(a,b,c)
    d = (b^2)-(4*a*c);
    z1 = (-b-sqrt(d))/(2*a);
    z2 = (-b+sqrt(d))/(2*a);
end

Note: Please provide the output if you want according to it.


Related Solutions

Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m,...
Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m, that uses vector-matrix multiplication to tabulate and display the cost of each of the following orders. Assume that a hot dog costs $3.00, a brat costs $3.50, and a Coke costs $2.50. ----------------------------------------------------   hot dogs brats cokes order 1    2 1 3 order 2 1 0 2 order 3 2 2 2 order 4 0 5 1
Write a C++ program that solves a quadratic equation to find its roots. The roots of...
Write a C++ program that solves a quadratic equation to find its roots. The roots of a quadratic equation ax2 + bx + c = 0 (where a is not zero) are given by the formula (–b ± sqrt(b2 – 4ac)) / 2a *Use #include for the use of sqrt. The value of the discriminant (b2 – 4ac) determines the nature of roots. If the value of the discriminant is zero, then the equation has a single real root. If...
Write a program to input the coefficients of a quadratic equation and solve roots for all...
Write a program to input the coefficients of a quadratic equation and solve roots for all cases (including complex roots). VBA. x=(b ^2) - (4ac) I have it for 2 complex and 2 real and repeated. Is that all cases?
Write a MATLAB program to generate a Gaussian window and apply it to a signal as...
Write a MATLAB program to generate a Gaussian window and apply it to a signal as follows: 1)Generate a time vector from 0 to 1 seconds with an interval of 0.001 second 2)Generate two sinusoid signals with a frequency of 90 Hz and 100 Hz, respectively, and add them together 3)Generate a Gaussian window and apply it to the combined sinusoid signal 4)Plot an overlay of the original signal and the windowed in the same figure 5)Add a legend to...
MATLAB Write a script which asks the user of the program to provide an initial horizontal...
MATLAB Write a script which asks the user of the program to provide an initial horizontal position, initial vertical position, initial velocity, and angle. Create a time vector spanning from zero seconds to 100 seconds incremented at 0.01 seconds. Call the function that you created in the previous problem to calculate the trajectory and velocities of the projectile. Find the maximum height of the projectile and the time at which it reaches that point. Write a neat sentence stating what...
Write a program usingif-elseif-else statements to calculate the real roots of a quadratic equation ax^2+bx+c=0
Write a program usingif-elseif-else statements to calculate the real roots of a quadratic equation ax^2+bx+c=0
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops,...
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops, evaluate the multivariable function: z = sin ⁡ ( x ) cos ⁡ ( y ) for x between -4 and 4 in steps of 1 y between -2 and 2 in steps of 1 Display the matrix z Cut and paste the following into a word doc and submit to this question. Your script code Your input Your output
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as...
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as well as the tank dimensions in feet. Assume that the initial measurements are 7 meters in diameter and 11 meters tall. Display your final answers to the screen using disp and a statement without a semicolon, e.g. write the following into your script disp(‘The capacity in U.S. gallons is:’), capacity, where capacity is a variable that you defined in preceding calculations. Part B: In...
• In this script, write MATLAB code to create an array A of size 100 ×...
• In this script, write MATLAB code to create an array A of size 100 × 3. The first column should contain random numbers between 0 and 10. The second column should also contain random numbers between 0 and 10. The third column should contain random integers between 20 and 50. The first two columns represent the x and y coordinates of a map, respectively. The third column represents the height of buildings. For example, if the first row of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT