You are on page 1of 10

Linear Algebra with MATLAB

Daw Marlar Win Khin


Associate Professor
Faculty of Computing
UCSY
Linear Algebra with MATLAB Row Operations in MATLAB

In MATLAB the 𝑖𝑡ℎ 𝑟𝑜𝑤 𝑜𝑓 𝑎 𝑚𝑎𝑡𝑟𝑖𝑥 𝐴 is specified by 𝐴(𝑖, :). Thus to replace the
3𝑟𝑑 𝑟𝑜𝑤 𝑜𝑓 𝑎 𝑚𝑎𝑡𝑟𝑖𝑥 𝐴 by twice itself, we need only type:
𝐴 3, : = 2 ∗ A(3, ∶)

Similarly, we can divide 𝑖𝑡ℎ 𝑟𝑜𝑤 𝑜𝑓 𝑎 𝑚𝑎𝑡𝑟𝑖𝑥 𝐴 by the nonzero number c by typing

𝐴 𝑖, : = A(i, ∶)/c

Presented by MLWK
Linear Algebra with MATLAB Row Operations in MATLAB

Suppose we want to add 𝑐 𝑡𝑖𝑚𝑒𝑠 𝑡ℎ𝑒 𝑖𝑡ℎ 𝑟𝑜𝑤 𝑡𝑜 𝑡ℎ𝑒 𝑗𝑡ℎ 𝑟𝑜𝑤, then we type
𝐴(𝑗, : ) = 𝐴(𝑗, : ) + 𝑐 ∗ 𝐴(𝑖, : )

Presented by MLWK
Linear Algebra with MATLAB Row Operations in MATLAB

In MATLAB, 𝑡ℎ𝑒 𝑖𝑡ℎ 𝑎𝑛𝑑 𝑗𝑡ℎ 𝑟𝑜𝑤𝑠 𝑜𝑓 𝑡ℎ𝑒 𝑚𝑎𝑡𝑟𝑖𝑥 𝐴 are permuted by the command

𝐴([𝑖 𝑗], : ) = 𝐴([𝑗 𝑖], : )

Presented by MLWK
Linear Algebra with MATLAB Row Operations in MATLAB

x + 2y +z = 2
3x + 8y +z = 12
4y +z = 2
1 2 1 𝑥 2
𝐴= 3 8 1 𝑥= 𝑦 𝑏 = 12
0 4 1 𝑧 2

Presented by MLWK
Linear Algebra with MATLAB Row Operations in MATLAB

𝑥 + 2𝑦 + 𝑧 = 2

2𝑦 − 2𝑧 = 6

5𝑧 = −10

z = −2 𝑦=1 𝑥=2
Presented by MLWK
Linear Algebra with MATLAB Row Operations in MATLAB

x + 2y +z = 2
3x + 8y +z = 12
4y +z = 2
1 2 1 𝑥 2
𝐴= 3 8 1 𝑥= 𝑦 𝑏 = 12
0 4 1 𝑧 2

Presented by MLWK
Linear Algebra with MATLAB Reduced Echelon Form in MATLAB

Presented by MLWK
Linear Algebra with MATLAB Exercises

Presented by MLWK
Thanks for your attention.

You might also like