neilofbodom
Member
Hi guys
I'm implementing the Newton-Raphson method in Matlab. It works fine, but the only problem is that the values are being printed as fractions and not as decimals. I tried using format long but absolutely nothing happened.
My code:
syms x
f(x) = (x^2) - 40;
df = diff(f,x);
x(1) = 6;
for i = 1:10
format long;
x(i+1) = x(i)-(f(x(i))/df(x(i)));
disp(' Iterate ');
disp(i);
disp(' X ');
disp(x(i));
end
Any ideas?
Cheers
I'm implementing the Newton-Raphson method in Matlab. It works fine, but the only problem is that the values are being printed as fractions and not as decimals. I tried using format long but absolutely nothing happened.
My code:
syms x
f(x) = (x^2) - 40;
df = diff(f,x);
x(1) = 6;
for i = 1:10
format long;
x(i+1) = x(i)-(f(x(i))/df(x(i)));
disp(' Iterate ');
disp(i);
disp(' X ');
disp(x(i));
end
Any ideas?
Cheers