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

4 visualizaciones (últimos 30 días)
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;

Respuestas (0)

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by