Problem #2 (30 points): a) Let the mathematical function f(x) be defined as: f (
ID: 3738560 • Letter: P
Question
Problem #2 (30 points): a) Let the mathematical function f(x) be defined as: f (x) - exp(-0.5x) cos(10x) Write a Matlab function called Bisection1 that would find the zero based on a passing input arguments x0 & x1 which defines the initial interval [x0,x1] The function should starts as: function x-Bisection1(x0) % enter your code here end Submit the function as a .m file. Apply different initial interval to find the zero [0, 0.1]. Hint: the while loop should have the following statement: while((abs (fx)>delta f)) %where n is the iteration number endExplanation / Answer
SAVE THE FOLLOWING CODE IN MATLAB AND GET THE RESULTS-
Save the following function file in Matlab-
function Bisection1(x0,x1)
X0=length(x0);
a=0;
b=0;
for i=1:X0
if x0(i)==0
a=a+1;
elseif x1(i)==0
b=b+1;
end
end
disp(a)
disp(b)
Save the following .m file in Matlab
clc
clear
close all;
number_of_non_zeros=Bisection1([1 0 3 2 0],[2 0 4 0 2]);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.