How to run this code on any inputs?Newton
Mostrar comentarios más antiguos
function [p,k] = newton(f,df,p0,tol)
for k=1:100
p = p0 - f(p0)/df(p0);
if abs(p-p0)<tol, break; end
p0 = p;
end
I have that but where do I put the tolerance, the function and everything else for it to run. I'm really new at all this.
4 comentarios
Geoff Hayes
el 21 de Sept. de 2014
cakey - presumably f and df are function handles and your code makes use of the function f and its derivative df. Also since you are using the tolerance tol as a condition to break out of the loop and the initial point p0, it isn't clear to me what you mean by where do I put the tolerance, the function and everything else for it to run. Please clarify what it is that you need help with.
cakey
el 22 de Sept. de 2014
Stephen23
el 22 de Sept. de 2014
Read about function handles, it might help. And use the contents browser, which is on the left-hand side of the help window, to discover related topics... it really is very handy!
Respuesta aceptada
Más respuestas (1)
Stephen23
el 22 de Sept. de 2014
1 voto
What you have is a function, which can be run to create some outputs. It could be good to revise MATLAB's comprehensive help on calling functions . If you are learning MATLAB, you will have to get used to doing a lot of reading of help pages. But don't worry, MATLAB's help pages are really quite good, with plenty of examples to try, and explanations of concepts that you need to understand. You should learn to navigate using the help contents browser too. Good luck!
1 comentario
cakey
el 23 de Sept. de 2014
Categorías
Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!