Matrices
1. A = [1 2; 3 4; 5 6]
![Rendered by QuickLaTeX.com A=\begin{pmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-0d8647d041e38aa7c4835814b2bd5688_l3.png)
2. size(A)
size of matrix
![Rendered by QuickLaTeX.com \begin{matrix} 3 & 2 \end{matrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-32eb6ba0725105fb7044bc778e95f8c6_l3.png)
3. size(A,1)
number of rows
ans = 3
4. size(A,2)
number of columns
ans = 2
5. A(3,2)
![Rendered by QuickLaTeX.com A_{32}](https://teach.sg/wp-content/ql-cache/quicklatex.com-ac5aab20333e1ad5073cdeccfc4bbf50_l3.png)
ans = 6
6. A(2,:)
every element along row 2
![Rendered by QuickLaTeX.com \begin{pmatrix} 3 & 4 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-4d612ffac9a62e60b99e9080c1bcb91e_l3.png)
7. A(:,1)
every element along column 1
![Rendered by QuickLaTeX.com \begin{pmatrix} 1\\ 3\\ 5 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-a891132f513666248677062e54e48e2b_l3.png)
8. A([1 3],:)
every element along rows 1 and 3
![Rendered by QuickLaTeX.com \begin{pmatrix} 1 & 2\\ 5 & 6 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-8ac358bff0652c6268a917eb808bf20c_l3.png)
9. A(:,2) = [10; 11; 12]
replace column 2 with new elements
![Rendered by QuickLaTeX.com \begin{pmatrix} 1 & 10 \\ 3 & 11 \\ 5 & 12 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-5ba41ae27ccd9008a69aec478f9eeb60_l3.png)
10. A = [A, [100; 101; 102]]
append new column vector to the right
![Rendered by QuickLaTeX.com \begin{pmatrix} 1 & 10 & 100 \\ 3 & 11 & 101\\ 5 & 12 & 102 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-ca7d76c94cce0f4f3ae25a59ec850e99_l3.png)
11. A(:)
put all elements of A into a single vector
![Rendered by QuickLaTeX.com \begin{pmatrix} 1\\ 3\\ 5\\ 10\\ 11\\ 12\\ 100\\ 101\\ 102 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-0a74f6f304c5eb1b06c4c69b7492d397_l3.png)
12. A = [1 2; 3 4; 5 6]
B = [11 12; 13 14; 15 16]
C = [A B]
concatenating A and B
![Rendered by QuickLaTeX.com C=\begin{pmatrix} 1 & 2 & 11 & 12 \\ 3 & 4 & 13 & 14\\ 5 & 6 & 15 & 16 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-e94ec5c6c084fd13d05759f6c82999e3_l3.png)
13. C = [A; B]
putting A on top of B
![Rendered by QuickLaTeX.com C=\begin{pmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \\ 11 & 12 \\ 13 & 14 \\ 15 & 16 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-82db6d154e853d62b15a0295348e0871_l3.png)
14. v = [1 2 3 4]
![Rendered by QuickLaTeX.com v=\begin{pmatrix} 1 & 2 & 3 & 4 \end{pmatrix}](https://teach.sg/wp-content/ql-cache/quicklatex.com-39dfc02550a099b328096b84a7a50b3a_l3.png)
15. length(v)
length of vector v
ans = 4
Loading files
1. path: pwd
shows where Octave location is
2. change directory: cd '/Users/eugene/desktop'
3. list files: ls
4. load files: load featuresfile.dat
5. list particular file: featuresfile
6. check saved variables: who
7. check saved variables (detailed view): whos
8. clear particular variable: clear featuresfile
9. clear all: clear
10. restrict particular variable: v = featuresfile(1:10)
only first 10 elements from featuresfile
11. save variable into file: save testfile.mat v
variable v is saved into testfile.mat
12. save variable into file: save testfile.txt v -ascii
variable v is saved into text file