How can I center my table?
Show older comments
if true
A = [10 2 -1;-3 -6 2;1 1 5];
b = [27;-61.5;-21.5];
X = zeros(length(b),1);
error = ones(length(b), 1)*100;
iteration = 0;
fprintf('Iteration\t x1\t\t x2\t\t x3\t\tError1\t Error2\t\tError3\t\tMax. error\n')
while max(error) > 5
iteration = iteration + 1;
Z = X;
for i = 1:length(b)
j = 1:length(b);
Xnow = X;
Xnow(i) = 0;
X(i) = (b(i) - sum(A(i,j)*Xnow))/A(i,i);
end
error = abs((X - Z)./X)*100;
fprintf(' %4.0f\t\t%4.5f\t\t%4.5f\t\t%8.5f\t%4.2f%%\t %4.2f%%\t\t%4.2f%%\t %4.2f%%\n', iteration, X(1), X(2), X(3), error(1), error(2), error(3), max(error))
end
end
The code produces the table attached.
How can I straighten the values under Max. error and Error3?

Accepted Answer
More Answers (0)
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!