modified newton's method

조회 수: 10 (최근 30일)
Robin
Robin 2011년 11월 30일
I am new to matlab. How do apply a formula to an equation? EX. formula: x(sub n)=x(sub n-1) - m (f(xsub n-1)/ f'(xsub n-1) to eqn f(x) = x^3 -3x^2 + 4 = 0

답변 (1개)

bym
bym 2011년 12월 1일
one way is to use anonymous functions:
f = @(x) x^3-3*x^2+4;
fprime = @(x) 3*x^2-6*x;
then use a for loop to perform the iteration
x = zeros(10,1);
x(1)=.1
for i = 1:9
x(i+1) = x(i)-f(x(i))./fprime(x(i));
end

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by