f(x)=3x^3-5x^2+3x-7=0

5 ビュー (過去 30 日間)
Jobayer  Rahman
Jobayer Rahman 2016 年 10 月 17 日
編集済み: Walter Roberson 2023 年 8 月 6 日
%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;
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
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...

回答 (2 件)

Guillaume
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?
  1 件のコメント
Jobayer  Rahman
Jobayer Rahman 2016 年 10 月 17 日
x(1)=0 i need matrix value

サインインしてコメントする。


VBBV
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
1.0000 0 2.0000 2.3333 3.0000 1.9535 4.0000 1.8331 5.0000 1.8212 6.0000 1.8211 7.0000 1.8211
plot(kk,x); grid ; xlabel('Iteration [-]'); ylabel('x')

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by