Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB script that can do what is described in the image. Another bracke

ID: 2247939 • Letter: W

Question

Write a MATLAB script that can do what is described in the image.

Another bracketing method is Riddler's method as shown in the flowchart below construct an m- file for this function. Be sure to write the pseudocode before moving into MATLAB notation. Compare the number of iterations it takes to compute the root of f(x) = e^x - 25. Use 0 and 20 as the bounds. Use bisection, the false position (download from Canvas) and the ridder's function you just created. Evaluate each of these methods using an error tolerance of 0.001%.

Explanation / Answer

function [level, imgBw] = isodata(img, logArg) % isodata Compute global image threshold value using iterative isodata method. % % inputs: % img can be of any class. % logArg, if supplied and equal to 'log', will apply a log transform to the image prior to thresholding. % The log transform may result in a better threshold, if the variance of the foreground % is considerably higher than the variance of the background. % if your image has negative values, a log transform is not a good idea. % % outputs: % level is the calculated threshold. % even if logArg equals 'log', level is in units of the original image. % regardless of the class of img, level is a double. % imgBw is the thresholded (binary) image. % % JJH, 2013-11-09 % if nargin>1 && strcmp(logArg, 'log') img = log(double(img)); 1;end maxIteration = 1e2; tol = 1e-6; imgFlat = img(:); ii = 1; thresh(ii) = mean(imgFlat); while iithresh(ii); mbt = mean(imgFlat(~imgBw)); mat = mean(imgFlat(imgBw)); thresh(ii+1) = 0.5*(mbt + mat); if thresh(ii+1) - thresh(ii) > tol ii = ii + 1; else break 1;end;1;end level = thresh(end); if nargin>1 && strcmp(logArg, 'log') level = exp(level); 1;end function root = riddler(function, x1, x2, xaccuracy, N) xl = x1; xh = x2; fl=function(x1) fh=function(x2) for i = 1:N xm = 0.5*(xl+xh); fm = function(xm); s = sqrt(fm*fm - fl*fh) if s == 0 return; end xnew = xm + (xm - xl)*sign(fl - fh)*fm/s %update formula . . . % extra code to check convergence and assign final answer for root . % code to update xl, xh, fl, fh, etc. (i.e rebracket) . end % end for
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote