Moving Data (Octave)

Matrices
1. A = [1 2; 3 4; 5 6]
A=\begin{pmatrix}   1 & 2 \\   3 & 4 \\   5 & 6  \end{pmatrix}

2. size(A) size of matrix
\begin{matrix}   3 & 2  \end{matrix}

3. size(A,1) number of rows
ans = 3

4. size(A,2) number of columns
ans = 2

5. A(3,2) A_{32}
ans = 6

6. A(2,:) every element along row 2
\begin{pmatrix}   3 & 4  \end{pmatrix}

7. A(:,1) every element along column 1
\begin{pmatrix}   1\\   3\\   5  \end{pmatrix}

8. A([1 3],:) every element along rows 1 and 3
\begin{pmatrix}   1 & 2\\   5 & 6  \end{pmatrix}

9. A(:,2) = [10; 11; 12] replace column 2 with new elements
\begin{pmatrix}   1 & 10 \\   3 & 11 \\   5 & 12  \end{pmatrix}

10. A = [A, [100; 101; 102]] append new column vector to the right
\begin{pmatrix}   1 & 10 & 100 \\   3 & 11 & 101\\   5 & 12 & 102  \end{pmatrix}

11. A(:) put all elements of A into a single vector
\begin{pmatrix} 1\\ 3\\ 5\\ 10\\ 11\\ 12\\ 100\\ 101\\ 102  \end{pmatrix}

12. A = [1 2; 3 4; 5 6]
B = [11 12; 13 14; 15 16]
C = [A B] concatenating A and B
C=\begin{pmatrix}   1 & 2 & 11 & 12 \\   3 & 4 & 13 & 14\\   5 & 6 & 15 & 16  \end{pmatrix}

13. C = [A; B] putting A on top of B
C=\begin{pmatrix}   1 & 2 \\   3 & 4 \\   5 & 6 \\   11 & 12 \\   13 & 14 \\   15 & 16   \end{pmatrix}

14. v = [1 2 3 4]
v=\begin{pmatrix}   1 & 2 & 3 & 4  \end{pmatrix}

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

loading
×