{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

FindRoots

# FindRoots - f function Roots = FindRoots(F,xMin,xMax F is a...

This preview shows pages 1–2. Sign up to view the full content.

function Roots = FindRoots(F,xMin,xMax) f % F is a handle to a function of a single variable that is defined on the % interval [xMin,xMax]. % Roots is a row vector--possibly empty--of roots of F in the interval % Roots established via a graphical interface: click the blue rectangle to % highlight AND find the root AND add it to the vector Roots if, in the % green interval L-->R, the function crosses the x axis only once. % Click in red interval = zoom out / Click in green = zoom in. % % Set up x based on xMin and xMax: % x = linspace(xMin,xMax,100000); x % Store fcn values in y: % y = MyF(x); y yMax = max(abs(y)); y yMin = -yMax; y Roots = []; % Out put of fcn. initialized as an empty vector R [a, b] = BWindow(x,y,Roots); % Call function BWindow for click coordinates [ % if x coordinate of mouse click is between xMax and xMin, continue loop: % while (a<=xMax)&&(a>=xMin) w % a is less than L OR greater than R: if (a<(xMin + (1/4)*(xMax - xMin)))||((a>(xMin + (3/4)*(xMax - xMin)))) interval = xMax-xMin; xMaxNew = a + interval; % ZOOM OUT xMinNew = a - interval; % you clicked in display rectangle

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}