What is wrong in this code?!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Beso_h
am 13 Nov. 2020
Kommentiert: Beso_h
am 13 Nov. 2020
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
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 13 Nov. 2020
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 Kommentare
Stephen23
am 13 Nov. 2020
R2007b does not permit functions to be defined in scripts.
The feature of defining functions in scripts was introduced with R2016b:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
