A = [1 2;3 4; 5 6] A = 1 2 3 4 5 6
size () returns the size of the matrix
size(A) ans = 3 2
Returns the number of rows A
size (A, . 1 ) ANS = . 3
Returns the number of columns of A
size(A,2) ans = 2
Returns the maximum dimensions for v
>> v = [1 2 3 4] v = 1 2 3 4 >> length(v) ans = 4
A return to the maximum dimension (A 3 * 2)
>> length(A) ans = 3
File Handling
octave installation path
>> pwd ans = G:\octave\octave-5.1.0-w64
ls displays the file in the current directory structure
>> ls Volume in drive G is 新新加加卷卷 Volume Serial Number is E45B-C624 Directory of G:\octave\octave-5.1.0-w64 [.] [etc] msys2.ico post-install.bat [..] fc_update.bat msys2_shell.cmd README.html [clang32] HG-ID [notepad++] [tmp] [clang64] [home] octave-firsttime.vbs [usr] cmdshell.bat [mingw32] octave.vbs [var] [dev] [mingw64] [opt] 9 File(s) 40,592 bytes 14 Dir(s) 239,150,755,840 bytes free
cd into the path
>> cd 'C:\Users\22735\Desktop\os' >> pwd ans = C:\Users\22735\Desktop\os >> ls Volume in drive C has no label. Volume Serial Number is A4A1-9EDE Directory of C:\Users\22735\Desktop\os [.] [..] 0 File(s) 0 bytes 2 Dir(s) 67,279,585,280 bytes free
Download Data
load featureX.dat load ( ' featureX.dat ' )
who displays all defined variables
>> who Variables in the current scope: A I a ans c sz v w
whos display more detailed information
>> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== A 3x2 48 double I 4x4 32 double a 1x1 8 double ans 1x25 25 char c 3x4 96 double sz 1x2 16 double v 1x4 32 double w 1x10000 80000 double Total is 10066 elements using 80257 bytes
clear delete variables
>> clear I >> who % I已经不见了 Variables in the current scope: A a ans c sz v w
The first 10 data priceY is assigned to v
>> v = priceY(1:10) v = 0.134924 0.065742 0.863374 0.139802 0.677121 0.654762 0.141145 0.228309 0.789854 0.451826
The data stored in the hard disk
>> save hello.txt v;
>> save hello.txt v -ascii; % save as text(ASCII)ASCII格式
clear deletes all the variables
>>clear
A (m, n) matrix obtaining a specific value
>> A A = 1 2 3 4 5 6
>> A(3,2)
ans = 6
A (m, :) m-th row data acquisition
>> A(2,:) ans = 3 4
A (:, n) of the n-th column data acquisition
>> A(:,1) ans = 1 3 5
: Colon behalf of the line or the column of all data
A matrix display data of the first row and the third row
>> A([1 3], :) ans = 1 2 5 6
Replace the element according to the ranks
>> A(:,2) = [10;11;12] A = 1 10 3 11 5 12
Add the column vector B = [A, [column vector]]
>> A = [A,[100; 101; 102]] A = 1 10 100 3 11 101 5 12 102
A column vector will be displayed as
>> A(:) ans = 1 3 5 10 11 12 100 101 102
Two binding matrix C = [AB]
>> B = [A,A] B = 1 10 100 1 10 100 3 11 101 3 11 101 5 12 102 5 12 102
Vertical placement C = [A; B]
>> B = [A;A] B = 1 10 100 3 11 101 5 12 102 1 10 100 3 11 101 5 12 102