0% found this document useful (0 votes)
204 views5 pages

Lab 5 Gauss Elimination

The document discusses using Gauss elimination method in MATLAB to solve systems of linear equations. It provides two examples of MATLAB code to solve sets of linear equations. The code uses Gauss elimination to put the coefficient matrix into reduced row echelon form, then back substitution to solve for the variables. The results of running the code on the two examples are presented. The conclusion states that the lab helped learn matrix operations in MATLAB and how to use Gauss elimination and back substitution to find roots of systems of linear equations.

Uploaded by

Faraz Ali Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
204 views5 pages

Lab 5 Gauss Elimination

The document discusses using Gauss elimination method in MATLAB to solve systems of linear equations. It provides two examples of MATLAB code to solve sets of linear equations. The code uses Gauss elimination to put the coefficient matrix into reduced row echelon form, then back substitution to solve for the variables. The results of running the code on the two examples are presented. The conclusion states that the lab helped learn matrix operations in MATLAB and how to use Gauss elimination and back substitution to find roots of systems of linear equations.

Uploaded by

Faraz Ali Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING & TECHNOLOGY, PESHAWAR

MtE 350L Numerical Method


Student Name: Mian Sayaf Ali Shah Reg. No: 18PWMCT0612

Lab Tittle: Gauss Elimination Method

Lab No: 5

LAB REPORT RUBRICS:


Excellent (4) Proficient (3) Basic (2) Below Basic
Student’s
Criteria (1)
Score

Report is mostly Report is


Report is as per
as per the disorganized
the guidelines. Sections/Steps
To organize the lab guidelines and and follows
All are not ordered
report and practice most some guidelines
sections/steps are and Report is
the writing skills as sections/steps are but most of the
clearly organized not as per the
per the guidelines ordered well but guidelines are
in a logical guidelines
requires minor missing
order.
improvements.
The report
completely
The report
discusses the The report is
The report discusses the lab
To discuss the actual required task in totally
discusses the work but have
task own words with irrelevant to
required task irrelevant
some relevant the lab work
information
additional
information
Calculations and
Calculations and Most data and
data analysis were
data analyses observations
performed
were were recorded Calculations
To perform accurately, but
performed adequately, but and data
calculations and minor errors were
clearly, with several analyses of lab
data analysis made both in
concisely, and significant were missing
calculations and
accurately, with errors or
in applying
correct units. omissions.
correct units
Graphs, if
necessary, were Graphs, if Major
To present results Graphs, if
drawn accurately necessary, were components of
in the form of necessary, were
and neatly and drawn but lab were
graphs drawn adequately
were clearly inadequately. missing
labelled.
Numerical Methods
Lab Report # 5

Gauss Elimination Method

Submitted by: Mian Sayaf Ali Shah(18PWMCT0612)

Submitted to: Dr. Shahzad Anwar

Section: A

Submission Date (December 22, 2020)

DEPARTMENT OF MECHATRONICS ENGINEERING


University of Engineering and Technology, Peshawar, Pakistan
Objective:
 To know about basic computations of matrices in MATLAB
 To write the code for the Gauss Elimination method.
 To solve the system of linear equations and determine the roots.

Software:
 MATLAB

Theory:
Basically, we do computations and visualization in MATLAB. In this lab, we did the
computations. We learn how to write the matrices in MATLAB and perform the arithmetic
operations on matrices. We learn how to find roots of system of linear of equations by using
the gauss elimination and then use the back substitution method in MATLAB. Linear equations
have more than one variable. It gives a straight line when plotted in graph. Back substitution
means to transform the matrix in row echelon or reduced row echelon form. First, solve the last
equation and the move towards first. In gauss elimination method, we transform the matrix into
reduced echelon form.

Post Lab Tasks:


Write down the MATLAB Code for the following Equation using Gauss Elimination
Method.

12x-2y+3z=18
x+10y-2z=16
3x+y+15z=52
MATLAB Code:
%12x-2y+3z=18
%x+10y-2z=16
%3x+y+15z=52
A=[12 -2 3;1 10 -2;3 1 15]; %write matrix A
b=[18;16;52]; % write matrix b
[n,~]=size(A);
x=zeros(n,1);
%coding for forward elimination.
for i=1:n-1
m=A(i+1:n,i)/A(i,i);
A(i+1:n,:)=A(i+1:n,:)-m*A(i,:);
b(i+1:n,:)=b(i+1:n,:)-m*b(i,:);
end
%now coding for back substitution method.
x(n,:)=b(n,:)/A(n,n);
for i=n-1:-1:1
x(i,:)=(b(i,:)-A(i,i+1:n)*x(i+1:n,:))/A(i,i);
end
x
Results:

Figure 1 Result of Task 1

1.2x + 2.3y + 3.6z + 2.6t = 2.5


1.8x + 3.2y + 2.5z + 1.1t = 10.4
1.6x + 1.9y + 3.7z + 2.5t = 9.4
1.1x + 1.4y + 4.3z + 3.3t = 5.3
MATLAB Code:
%1.2x + 2.3y + 3.6z + 2.6t = 2.5
%1.8x + 3.2y + 2.5z + 1.1t = 10.4
%1.6x + 1.9y + 3.7z + 2.5t = 9.4
%1.1x + 1.4y + 4.3z + 3.3t = 5.3
A=[1.2 2.3 3.6 2.6;1.8 3.2 2.5 1.1;1.6 1.9 3.7 2.5;1.1 1.4 4.3 3.3]; %write
matrix A
b=[2.5;10.4;9.4;5.3]; % write matrix b
[n,~]=size(A);
x=zeros(n,1);
%coding for forward elimination.
for i=1:n-1
m=A(i+1:n,i)/A(i,i);
A(i+1:n,:)=A(i+1:n,:)-m*A(i,:);
b(i+1:n,:)=b(i+1:n,:)-m*b(i,:);
end
%now coding for back substitution method.
x(n,:)=b(n,:)/A(n,n);
for i=n-1:-1:1
x(i,:)=(b(i,:)-A(i,i+1:n)*x(i+1:n,:))/A(i,i);
end
x
Results:

Figure 2 Result of Task 2

Conclusion:
After performing this lab, we come to know about the computations in MATLAB and basic
operations that we did on matrices in MATLAB. We write the code for Gauss elimination
method to determine the roots of system of linear equations. We successfully determine the
roots of equations by transforming the matrix into reduce echelon form and then use the back
substitution.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy