f(x)=3x^3-5x^2+3x-7=0
5 ビュー (過去 30 日間)
古いコメントを表示
%fx=3x^3-5x^2+5x-7
%fdx=9x^2-10x+3
x(1);
kk(1)=1;
for k=1:100;
fx=3x(k)^3-5x(k)^2+3(k)-7;
fdx=9x(k)^2-10x(k)+3;
h=-fx/fdx;
x(k+1)=x(k)+h;
kk(k+1)=k+1;
if abx(h)<.0000001
break,end
end
disp([kk1'x'])
is it correct program...can you please check with your matlab program.my matlab getting some problem so that i ask you to just check and run for me.inform me the result...
0 件のコメント
回答 (2 件)
Guillaume
2016 年 10 月 17 日
I can tell you the result without even trying to run your code. it's going to error with Unexpected MATLAB expression on fx = 3x....
Perhaps you meant fx = 3*x...
Also, note that the line x(1); does absolutely nothing. Maybe you meant to assign a value to it?
VBBV
2023 年 8 月 6 日
編集済み: VBBV
2023 年 8 月 6 日
x(1) = 0; % assuming x(1) = 0
kk(1)=1;
for k=1:100;
fx=3*x(k)^3-5*x(k)^2+3*x(k)-7; % use multplication operator for products in each terms
fdx=9*x(k)^2-10*x(k)+3; % use multplication operator for products in each terms
h=-fx/fdx;
x(k+1)=x(k)+h;
kk(k+1)=k+1;
if abs(h)<.0000001 % there is no abx function in Matlab, it must be abs
break;
end
end
disp([kk' x']) % There is no kk1 array, instead it is kk as calculated inside the loop
plot(kk,x); grid ; xlabel('Iteration [-]'); ylabel('x')
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!