Docsity

MATLAB Tutorial for Solving Simultaneous Equations in CES 4141, Study notes of Civil Engineering

Toggle sidebar
bg1
CES 4141 Matlab_tut.fm page 1 of 1 2/5/02
CES 4141 Stress analysis
Using MATLAB to solve simultaneous equations
MATLAB is available as a desktop icon in the Weil 200 Civil Eng. Computing Lab.
MATLAB (MATrix LABoratory) is both a programming and interactive environment. It can be
used as a simple matrix calculator by entering commands line by line, or as an advanced
programming environment for complex numerical computation. For this class (CES 4141), we
will use it as a simple calculator to solve systems of simultaneous equations.
These notes will walk through using MATLAB to find the solution to the following system of
three equations. This represents the matrix system of equations
This is the same system used for the Gaussian Elimination notes. Recall the solution:
(1)
Solution using MATLAB
1) Double click the Matlab icon on the desktop of any 200 Weil machine. A window will appear
with the prompt >> This is the MATLAB environment, where all commands will be entered
2) Enter the K matrix above as follows, then hit the Enter (Return) key. There is a space between
each number. The ; indicates the start of the next row of numbers in K
>> K=[3 5 2 ; 2 3 -1 ; 1 -2 -3]
3) Enter the R vector as three different rows by separating numbers with ;
>> R=[8 ; 1 ; -1]
4) Solve the system by pre-multiplying both sides of K*r=R with the inverse of K
>> r = inv(K)*R
The results of each operation should be displayed after hitting the return key. Try this example and
get the solutions in Eq. (1) above. Now use the same method for any matrix you wish to solve.
Remember that K must be square, and R must have the same # of rows as K.
!!"#"
#$ %
%# &'
&%'#'
"&
"%
"#
(
&
&'
"
Stiffness matrix K unknown displacement vector r
load vector R
"&
"%
"#
#
&'
%
"

Partial preview of the text

Download MATLAB Tutorial for Solving Simultaneous Equations in CES 4141 and more Study notes Civil Engineering in PDF only on Docsity!

CES 4141 Matlab_tut.fm page 1 of 1 2/5/

CES 4141 Stress analysis

Using MATLAB to solve simultaneous equations

MATLAB is available as a desktop icon in the Weil 200 Civil Eng. Computing Lab.

MATLAB (MATrix LABoratory) is both a programming and interactive environment. It can be

used as a simple matrix calculator by entering commands line by line, or as an advanced

programming environment for complex numerical computation. For this class (CES 4141), we

will use it as a simple calculator to solve systems of simultaneous equations.

These notes will walk through using MATLAB to find the solution to the following system of

three equations. This represents the matrix system of equations

This is the same system used for the Gaussian Elimination notes. Recall the solution:

Solution using MATLAB

1) Double click the Matlab icon on the desktop of any 200 Weil machine. A window will appear

with the prompt >> This is the MATLAB environment, where all commands will be entered

2) Enter the K matrix above as follows, then hit the Enter (Return) key. There is a space between

each number. The ; indicates the start of the next row of numbers in K

>> K=[3 5 2 ; 2 3 -1 ; 1 -2 -3]

3) Enter the R vector as three different rows by separating numbers with ;

>> R=[8 ; 1 ; -1]

4) Solve the system by pre-multiplying both sides of K*r=R with the inverse of K

>> r = inv(K)*R

The results of each operation should be displayed after hitting the return key. Try this example and

get the solutions in Eq. (1) above. Now use the same method for any matrix you wish to solve.

Remember that K must be square, and R must have the same # of rows as K.

Stiffness matrix K

unknown displacement vector r

load vector R