How to run this code on any inputs?Newton
이전 댓글 표시
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
Geoff Hayes
2014년 9월 21일
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
2014년 9월 22일
Stephen23
2014년 9월 22일
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!
채택된 답변
추가 답변 (1개)
Stephen23
2014년 9월 22일
1 개 추천
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!
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!