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일

0 개 추천

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

Beso_h
Beso_h 2020년 11월 13일
ya i mean fprintf ,but when i run the code,it not work and give me error
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개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

제품

릴리스

R2007b

태그

질문:

2020년 11월 13일

댓글:

2020년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by