Can you please solve this problem on MATLAB please make sure
Can you please solve this problem on MATLAB. please make sure to give me an error for imaginary number. Thanks a lot
Solution
%matlab code here
function [ x1,x2 ] = froot( a,b,c )
%FROOT Summary of this function goes here
% Detailed explanation goes here
h=b^2-4*a*c;
if h<0
error(\'roots are imaginary\');
abort;
else
x1=(-b+sqrt(h))/(2*a);
x2=(-b-sqrt(h))/(2*a);
end
end
---------------------------------
>> froot(1,-1,12)
Error using froot (line 7)
roots are imaginary
--------------------------------
>> [x1 x2]=froot(4,13,-17)
x1 =
1
x2 =
-4.2500
-----------------------------------------
>> [x1 x2]=froot(2,-4,2)
x1 =
1
x2 =
1
![Can you please solve this problem on MATLAB. please make sure to give me an error for imaginary number. Thanks a lotSolution%matlab code here function [ x1,x2 ] Can you please solve this problem on MATLAB. please make sure to give me an error for imaginary number. Thanks a lotSolution%matlab code here function [ x1,x2 ]](/WebImages/10/can-you-please-solve-this-problem-on-matlab-please-make-sure-1004062-1761517434-0.webp)