I need to have a table containing iter, xr, func(xr), and es for each iteration of the loop. I have tried listing them as arrays but cannot seem to get that to work.
function[root,ea,iter]=secant(func,delta,xr,es,maxit,varargin)if nargin<3,error('atleast 3 input arguments required'),endif nargin<4|isempty(es),es=0.0001;endif nargin<5|isempty(maxit),maxit=50;enditer=0;while (1) xrold=xr; xr=xr-((delta*xr*func(xr))/(func(xr+(delta*xr))-func(xr))); iter=iter+1; if xr~=0, ea=abs((xr-xrold)/xr)*100;end if ea<=es|iter>=maxit,break,end funcxr=func(xr); endroot=xr;
Best Answer