Matlab-style short-circuit operation performed for operator & , Inline function, Fixed Point, Starting Point
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Walter Roberson
el 6 de Oct. de 2015
Please show a sample input.
Note: your code defines "inc" as an output but never assigns a value to it.
Respuestas (0)
Ver también
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!