Printing cell array elements

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Online Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by