Question

In: Electrical Engineering

how to write coding in matlab using gauss elimination method for equation 10a + 50b +...

how to write coding in matlab using gauss elimination method for equation

10a + 50b + 20c + 10d = 100

5a + 15b + 75c - 25d=200

25a -15c - 5d = 300

10a + 20b - 30c + 100d = 400

Solutions

Expert Solution

MATLAB code is given below in bold letters.

function C = gauss_elimination(A,B) % defining the function
A= [ 10 50 20 10; 5 15 75 -25;25 0 -15 -5; 10 20 -30 100 ] % Inputting the value of coefficient matrix
B = [100; 200; 300; 400] % % Inputting the value of coefficient matrix
i = 1; % loop variable
X = [ A B ];
[ nX mX ] = size( X); % determining the size of matrix   
while i <= nX % start of loop
if X(i,i) == 0 % checking if the diagonal elements are zero or not
disp('Diagonal element zero') % displaying the result if there exists zero
return
end
X = elimination(X,i,i); % proceeding forward if diagonal elements are non-zero
i = i +1;
end
C = X(:,mX);

function X = elimination(X,i,j)
% Pivoting (i,j) element of matrix X and eliminating other column

% elements to zero

[ nX mX ] = size( X);
a = X(i,j);
X(i,:) = X(i,:)/a;
for k = 1:nX % loop to find triangular form
if k == i
continue
end
X(k,:) = X(k,:) - X(i,:)*X(k,j); % final result
end

RESULT:

a b c and d are given below.


a = 15.1209
b = -3.3912
c = 3.7692
d = 4.2969


Related Solutions

Show and explain Gauss-Jordan elimination using Matlab.
Show and explain Gauss-Jordan elimination using Matlab.
Using Matlab's FUNCTION FILE Solve this system of equations using Gauss Elimination in MATLAB by writing...
Using Matlab's FUNCTION FILE Solve this system of equations using Gauss Elimination in MATLAB by writing a Function file. 10y + z = 2 x + 3y – z = 6 2x + 4y + z = 5 Could you also provide me with a copiable function file of Matlab and the associated screenshot. Thank you!
1) Solve the system of linear equations, using the Gauss-Jordan elimination method. (If there is no...
1) Solve the system of linear equations, using the Gauss-Jordan elimination method. (If there is no solution, enter NO SOLUTION. If there are infinitely many solutions, express your answer in terms of the parameters t and/or s.) 3y + 2z = 1 2x − y − 3z = 4 2x + 2y − z = 5 (x, y, z) = 2) Solve the system of linear equations, using the Gauss-Jordan elimination method. (If there is no solution, enter NO SOLUTION....
Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 2y + z...
Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 2y + z = 3 x + z = 2 4y − 3z = 13 solve for x,y,x
Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 3y - 2z...
Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 3y - 2z = 8 3x - 2y + 2z = 2 4x - y + 3z = 2 (x, y, z) = ?
1) Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 4y −...
1) Solve the system of linear equations using the Gauss-Jordan elimination method. 2x + 4y − 6z = 56 x + 2y + 3z = −2 3x − 4y + 4z = −21 (x, y, z) = 2) Solve the system of linear equations using the Gauss-Jordan elimination method. 5x + 3y = 9 −2x + y = −8 (x, y) =
Solve the system using either Gaussian elimination with back-substitution or Gauss-Jordan elimination. (If there is no...
Solve the system using either Gaussian elimination with back-substitution or Gauss-Jordan elimination. (If there is no solution, enter NO SOLUTION. If the system has an infinite number of solutions, express x, y, z, and w in terms of the parameters t and s.) 4x + 12y − 7z − 20w = 20 3x + 9y − 5z − 28w = 36 (x, y, z, w) = ( ) *Last person who solved this got it wrong
how can I change the Gauss-Seidel method to SOR method code in Matlab? The question has...
how can I change the Gauss-Seidel method to SOR method code in Matlab? The question has shows that In implementing SOR method in MATLAB, one should not calculate Tw and cw by formulas Tw = (D -wL)^(-1)[(1-w)D+wU)] and Cw = w(D-wL)^(-1)b , where w stands for omega and using MATLAB's built-in inv function, since this function requires O(n^3) flops and therefore the whole matter loses its point. I have tried for many times but I can't get the correct answers....
QUESTION: USING MATLAB, Carry out three iterations of the Gauss-Seidel method, starting from the initial vector...
QUESTION: USING MATLAB, Carry out three iterations of the Gauss-Seidel method, starting from the initial vector Use the  ,  and  norm to calculate the residual error after each iteration, until all errors are below 0.0001. [Use 5 decimal place accuracy in you calculations]
Write a MATLAB function function = pivGauss(.....) to solve linear equations using Gaussian Elimination with Partial...
Write a MATLAB function function = pivGauss(.....) to solve linear equations using Gaussian Elimination with Partial Pivoting. You'll need to employ Nested Loops. Thank you !
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT