What is wrong in this code?!

3 ビュー (過去 30 日間)
Beso_h
Beso_h 2020 年 11 月 13 日
コメント済み: Beso_h 2020 年 11 月 13 日
f=@ (x) cos(x)+1/(1+x^2);
fd=@(x) -sin(x)-2*x/(1+x^2);
root=NewtonRaphson(f,fd,1.5,0.05,10);
function Xs=NewtonRaphson(Fun,Funder,Xo,Err,imax)
disp('Values in each iteration : ')
for(i=1:imax)
Xi=Xo-Fun(Xo)/Funder(Xo);
disp(Xi) if(abs((Xi-Xo)/Xo)<Err)
Xs=Xi; break end X0=Xi;
end
if(i==imax)
fprint('Solution not obtaind in %i iteration',imax)
Xs=('No Answer');
end
end

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 11 月 13 日
Well, what are you seeing that is incorrect?
Some suggestions - the code is formatted incorrectly, causing runtime errors.
There is no MATLAB function called fprint. Did you instead mean to use fprintf?
  3 件のコメント
Stephen23
Stephen23 2020 年 11 月 13 日
R2007b does not permit functions to be defined in scripts.
The feature of defining functions in scripts was introduced with R2016b:
Beso_h
Beso_h 2020 年 11 月 13 日
ah okay ,thanks ❤😊

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by