[Machine Learning] Octave Moving data around
阿新 • • 發佈:2020-08-17
Load data:
load featuresX.dat
who: Check how many variables in your current session:
who
whos: details about variables:
whos
Clear one variable:
clear M # delete the M variable
Clear all variables:
clear
Save the data into file:
save hello.mat v # save v variable into a file called hello.mat
Save as readable with -ascii:
save hello.txt v -ascii # save as text (ASCII)
Access one element in Metrix:
A = [1 2; 3 4; 5 6] A(3, 2) # 6
Access one row/column:
A(2, :) # ':' means every element along that row/column # 3 4
>> A(:, 2) # get second column data """ ans = 2 4 6"""
Access multi rows/columns:
>> A([1, 3], :) # get row 1 & 3 """ ans = 1 2 5 6 """
Assign one column/row:
>> A(:, 2) = [10; 11; 12] # assign second column """ A = 1 10 3 11 5 12 """
Append another column vector to right:
>> A = [A, [100; 101; 102]] A= 1 10 100 3 11 101 5 12 102
Put all element of A into a single vector:
>> A(:)
ans =
1
3
5
10
11
12
100
101
102
Concat two matrixs:
>> A = [1 2; 3 4; 5 6] A = 1 2 3 4 5 6 >> B = [10 11; 12 13; 14 15] B = 10 11 12 13 14 15 >> C = [A B] C = 1 2 10 11 3 4 12 13 5 6 14 15 >> D = [A; B] D = 1 2 3 4 5 6 10 11 12 13 14 15