Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Matlab Question the equation is ax^2 + bx +c = 0 please include notes My work: not sure how to continue... function [x1, x2] =

Matlab Question

image text in transcribed

the equation is ax^2 + bx +c = 0

please include notes

My work: not sure how to continue...

function [x1, x2] = myquadratic(a, b, c)

if isscalar(a) && isscalar(b) && isscalar(c)

x1 = (-b + sqrt(b^2 - 4*a*c)) / (2*a);

x2 = (-b - sqrt(b^2 - 4*a*c)) / (2*a);

Create a function called muquadratic, which has three inputs: a,b, and c, and has two outputs: x1 and x2. Inside the function, compute the two roots (x1 and x2) of the quadratic polynomial which is formed using the following expression: a2+6x2+c=0 Directly use the quadratic formula to solve for each of the two roots; do not use the roots() command. The first output should be the smaller of the two roots. Your function should work with scalar values for a,b, and c, as well as when the input variables are one-dimensional arrays of coefficients. The two output variables in this case should also be one-dimensional arrays of the same size as the inputs. Test your function by running it in the Command Window with the following inputs: mxquadratic(1,11,10)ans=[y,z]=mxquadratic([112],[1116,[1030])y=ans10=10y=5[y,z]=myquadratic(1,11,10)z=y=13z=1 Your function m-file should be saved with the same name as your function. Do not display any intermediate results from your function; all lines which display outputs should be semicolonterminated. Do not use the disp() function. All inputs should be passed into to the function through functions calls; do not use the input() function. You may use vectorization or a loop to handle the non-scalar-input cases

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions