Printing cell array elements

2 visualizzazioni (ultimi 30 giorni)
Ali Kiral
Ali Kiral il 6 Nov 2022
Modificato: VBBV il 6 Nov 2022
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?

Risposta accettata

VBBV
VBBV il 6 Nov 2022
Modificato: VBBV il 6 Nov 2022
fprintf(' the root estimates xr=[x1;x2;...;xn] are: \n%f', R)
Missing format specifier

Più risposte (0)

Categorie

Scopri di più su Online Estimation in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by