Question

The pscudocode shown below solves a system of n linear algebraic equations using Gauss-Jordan 125] elimination. DOFOR -1,n DO
0 0
Add a comment Improve this question Transcribed image text
Answer #1

%% function

function x = Gaussjordan( a, n )
% This function solves linear algebric equations using Gauss-Gordan method
% Inputs are a and n
% a is augmented matrix consiting of the coefficent matrix and the right
% hand side vector
% n is number of equations

for k = 1:n
for i = k+1:n+1
a(k,i) = a(k,i)/a(k,k);
end
a(k,k) = 1;
for i = 1:n
if(i~=k)
for j = k+1:n+1
a(i,j) = a(i,j) - a(k,j)*a(i,k);
end
end
end
end
for m =1:n
x(m) = a(m, n+1);
end
end

%% main code

clc
clear all
A = [ 2 -3 4; 4 2 -1 ];
n = 2;
x = Gaussjordan(A,n);
fprintf('Reqired solutions\n');
for i = 1:n
fprintf('x(%d) = %0.4f\n',i,x(i));
end

Add a comment
Know the answer?
Add Answer to:
The pscudocode shown below solves a system of n linear algebraic equations using Gauss-Jordan 125] elimination. DOFOR -1,n DOPOR 1 = k + 1,n + 1 END DO ae 1 DOFOR 1 = 1, n k THEN IF i DOFOR j- k+...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT