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

3 vues (au cours des 30 derniers jours)
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;
  1 commentaire
Walter Roberson
Walter Roberson le 6 Oct 2015
Please show a sample input.
Note: your code defines "inc" as an output but never assigns a value to it.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by