Printing cell array elements

2 ビュー (過去 30 日間)
Ali Kiral
Ali Kiral 2022 年 11 月 6 日
編集済み: VBBV 2022 年 11 月 6 日
Below script is an application of Newton's method to solve a set of nonlinear equations. Here we have 3 equations in 3 unknowns. All things starting with f is a function m-file. The script generates a cell array x having 9 3x1 arrays. These 3x1 arrays are estimates of three unknowns. I want to print the triple of estimates for each iteration (every time while loop runs)
a=input('Enter the guess for the first variable ');
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
b=input('Enter the guess for the second variable ');
c=input('Enter the guess for the third variable ');
k=input('Enter the accuracy ');
x{1}=[a;b;c]; i=1;
F=[f1(a, b ,c); f2(a, b ,c); f3(a, b ,c)];
while max(abs(F))>=10^-k
J=[f1x1(a, b ,c) f1x2(a, b ,c) f1x3(a, b ,c);f2x1(a, b ,c) f2x2(a, b ,c) f2x3(a, b ,c);f3x1(a, b ,c) f3x2(a, b ,c) f3x3(a, b ,c)];
F=[f1(a, b ,c); f2(a, b ,c); f3(a, b ,c)];
y=J\-F;
x{i+1}=x{i}+y;
R=[x{i+1}(1);x{i+1}(2);x{i+1}(3)];
fprintf(' the root estimates xr=[x1;x2;...;xn] are: \n', R)
a=x{i+1}(1);
b=x{i+1}(2);
c=x{i+1}(3);
F=[f1(a, b ,c); f2(a, b ,c); f3(a, b ,c)];
i=i+1;
end
MATLAB does not show R, only prints 'the root estimates..' Why does it do so? Is there a problem with the formation of R?

採用された回答

VBBV
VBBV 2022 年 11 月 6 日
編集済み: VBBV 2022 年 11 月 6 日
fprintf(' the root estimates xr=[x1;x2;...;xn] are: \n%f', R)
Missing format specifier

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by