Matlab-style short-circuit operation performed for operator & , Inline function, Fixed Point, Starting Point

10 views (last 30 days)
Hello everybody, I'd appreciate if you help me to find out where the problem is.
I run the same code with different inline functions, for ones it works, but for this one I get the warning when running :
////////////////////inline function that doesn't work
phi = inline('1-sin(2*x)', 'x')
////////////////////the warning I get
warning: Matlab-style short-circuit operation performed for operator &
warning: called from
fixpoint at line 22 column 9
ans = Inf
//////////////////code itself
function [p,res,niter,inc]=fixpoint(phi, x0,tol,nmax,varargin)
c = x0;
phix = feval(phi,c,varargin{:});
niter = 0;
diff = tol+1;
while diff >= tol & niter <= nmax
niter = niter + 1;
diff = abs(phix - c);
c = phix;
phix = feval(phi,c,varargin{:});
end
if niter > nmax
fprintf(['fixpoint stopped without converging to the desired tolerance',...
'because the maximum number of iterations was reached\n']);
varargin{:}
end
p = c;
res = phix - c;
return;

Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!