Using MATLAB, what code will be added to the code below to show the error? Provide an explanation the code you've used.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Using MATLAB, what code will be added to the code below to show the error? Provide an explanation the code you've used.

Post by answerhappygod »

Using MATLAB, what code will be added to the code below to show
the error? Provide an explanation the code you've used.
(Hint: modify the line with %error code)
function [x,e]= Mbisect(f,a,b,n)
l=f(a); u=f(b);
if l*u > 0.0
error("wrong a and b, since F(a)*f(b) > 0.0")
end
disp('x y') %disp('x y error')
for i=1:n
x=(a+b)/2;
y=f(x);
%error code
disp( [x y ]) %disp([x y er])
if y == 0.0
a=x;
b=x;
break
end
if l*y < 0.0
b=x;
else
a=x;
end
end
x=(a+b)/2;
e=(b-a)/2;
end
% Mbisect(inline('x^3 - 5','x'),1,2,10) "sample" (for this
activity set
% n=55)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply