フィルターのクリア

In what I missed

3 ビュー (過去 30 日間)
Saad Almalki
Saad Almalki 2020 年 12 月 7 日
コメント済み: VBBV 2020 年 12 月 8 日
function [ val, ea, iter] = IterMeth(x , es, maxit)
%%initialization
iter=12;
val = exp(1);
xr = [ ];
ea =100;
%iterative calculation
while (1)
xrold=xr;
xr= xr-x^iter/factorial(iter); <--------------------------here?
iter= iter+ 1;
if xr~=0
ea=abs((xr-xrold)/xr)*100;
end
if ea<=es || iter >= maxit,break,end
end
val=xr;
end
  8 件のコメント
VBBV
VBBV 2020 年 12 月 8 日
Ok. Is it same when there is keyword after comma ? In the e.g. you cited its a variable iter which changes values in the program
VBBV
VBBV 2020 年 12 月 8 日
%if true
if ea<=es || iter >= maxit,break,end
Give a value to maxit variable before it enter the while loop

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 12 月 7 日
編集済み: Walter Roberson 2020 年 12 月 7 日
xr = [ ];
That is empty.
xrold=xr;
so that is empty.
xr= xr-x^iter/factorial(iter); %<--------------------------here?
empty minus anything would be empty.
You are passing in x, but if it is not a scalar, you need
xr = xr - x.^iter ./ factorial(iter);

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by