0% found this document useful (0 votes)
54 views10 pages

Linear Systems and Matlab Programming

This document provides an overview of linear systems and MATLAB programming. It discusses solving linear systems using matrix algebra and the linsolve and inv commands in MATLAB. It also outlines some basic MATLAB programming concepts like naming scripts, if-else statements, for loops, and while loops. Examples are given for each concept to illustrate how they can be implemented in MATLAB code.

Uploaded by

STOCK MSOWOYA
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)
54 views10 pages

Linear Systems and Matlab Programming

This document provides an overview of linear systems and MATLAB programming. It discusses solving linear systems using matrix algebra and the linsolve and inv commands in MATLAB. It also outlines some basic MATLAB programming concepts like naming scripts, if-else statements, for loops, and while loops. Examples are given for each concept to illustrate how they can be implemented in MATLAB code.

Uploaded by

STOCK MSOWOYA
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/ 10

LINEAR SYSTEMS AND MATLAB

PROGRAMMING

L. Kanock
Graduate Civil Engineer
+265 295 519
[email protected]
Solving Linear Systems
• Linear systems are linear equations
with a number of unknowns

• They can be presented on a Matrix

• Basic linear system in the form of

Ax = b
Solving Linear Systems
• Example: • Present it in Matrix Form:

3 2 −1 𝑥 1
3x + 2y – z = 1
2 −2 4 𝑦 = −2
2x – 2y + 4z = -2 1
−1 2 −1 𝑧 0
-x + ½ y – z = 0
Solving Linear Systems
• To solve the linear system in MATLAB syntax
MATLAB

• Use one of the following


expressions:
x = A\b
x = linsolve(A,b)
x = Inv(A)*b
MATLAB Programming

Rules of Naming the script:


• MATLAB programming
is usually done in a
Script. • Start the script name with a
letter
• A code is written In the
script and run.
• Name can contain
• Your save the script in underscores and numbers
your working folder.
MATLAB Programming – if - else
statements

• The if-else statements


are used as logical
operators to help the
computer make
decisions.
MATLAB Programming - For loops
• The for Loop: • syntax
for i = [ 1 2 3 4 5 6 9]
The for loop is used to disp(i)
iterate a command for a end
finite number of times.
• This will display the
numbers
• You can use the colon
operator to create the
preferable range.
MATLAB Programming – while loops
The while loop: • The basic syntax is as
follows:
• This is used to iterate
a command while a n = 10
statement is true
total = 0
• While loops are
dangerous they can while total < n
run to infinity. total = total + 2
End
MATLAB Programming – while loops
• Application:
END

You might also like