Gaussian Elimination Script Help
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to use the attached script.
No matter what matrix, I always get a similar response:
Gaussian elimination completed successfully
it needed 0 row exchanges
x =
0
0
0
0
0
Test: the product A*x for this x is:
ans =
0
0
0
0
0
I've been trying to figure this out for a while now, and would really appreciate some help! Thanks.
1 Kommentar
John D'Errico
am 13 Mär. 2016
The simple answer is to learn to use the debugger. Use it to follow through your code at each step. Check on every line that it is doing something rational. It is not that hard to do once you learn how to use the tools.
HOWEVER...
You are a rarity, in that your code is actually reasonably well written. It is even documented. So I'll take a look at it.
Over the long term though, you will find your answer much sooner with the debugger.
Antworten (1)
John D'Errico
am 13 Mär. 2016
Bearbeitet: John D'Errico
am 13 Mär. 2016
Ok, I looked at your code. A serious MAJOR problem found.
You never finished writing the code. I'll list the pertinent lines of code:
% Backward substitution:
% perform on each vector b separately:
% Step B3:
disp('Gaussian elimination completed successfully');
fprintf('it needed %d row exchanges\n\n', counter);
Exactly where in there do you do the final steps?
Oh, by the way, there was a serious problem earlier in the code, but it will be non-fatal, MUCH of the time. Just serious.
When you compute the pivot element, you just test to see if it was zero. The idea behind pivoting is that you don't want to divide by a tiny number. So if your pivot element was 1e-16, the test will not look for another. Non-zero is non-zero after all.
The idea behind pivoting is to find the pivot element that is as LARGE as possible in magnitude. Then you divide by a big number. This lessens the errors in Gaussian elimination. It is why you use pivoting, because without pivoting, Gaussian elimination is not robust as an algorithm.
Perhaps the idea behind pivoting was missed by you, or perhaps that comes in your next class when that will be explained.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!