Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a function-function that uses the incremental search algorithm to find root brackets without using a for loop. In other words, vectorize your incremental search

  1. Create a function-function that uses the incremental search algorithm to find root brackets without using a for loop. In other words, vectorize your incremental search function. The inputs and outputs are the same as the code in Fig. 5.4 of your text (you can omit the input checking and bracket number display code). The first line of your code is as follows: function xb = incsearchv(func,xmin,xmax,ns)

FIG. 5.4:

function xb = incsearch(func,xmin,xmax,ns) % incsearch: incremental search root locator 
% xb = incsearch(func,xmin,xmax,ns): % finds brackets of x that contain sign changes % of a function on an interval % input: % func = name of function % xmin, xmax = endpoints of interval % ns = number of subintervals (default = 50) % output: % xb(k,1) is the lower bound of the kth sign change % xb(k,2) is the upper bound of the kth sign change % If no brackets found, xb = []. 
if nargin < 3, error('at least 3 arguments required'), end if nargin < 4, ns = 50; end %if ns blank set to 50 
% Incremental search x = linspace(xmin,xmax,ns); f = func(x); nb = 0; xb = []; %xb is null unless sign change detected for k = 1:length(x)1 

if sign(f(k)) ~= sign(f(k+1)) %check for sign change

nb = nb + 1; xb(nb,1) = x(k); xb(nb,2) = x(k+1);

end

end

if isempty(xb) %display that no brackets were found disp('no brackets found') disp('check interval or increase ns') 
else disp('number of brackets:') %display number of brackets disp(nb) 

end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago