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

3 ビュー (過去 30 日間)
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 件のコメント
Walter Roberson
Walter Roberson 2015 年 10 月 6 日
Please show a sample input.
Note: your code defines "inc" as an output but never assigns a value to it.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by