机器学习入门第三篇——Octave/Matlab Tutorial(3)
·
机器学习入门第三篇——Octave/Matlab Tutorial(3)
- Moving Data Around
- Compution on Data
Moving Data Around
pwd %显示路径

load %加载数据
loa() %加载数据

who %有哪些变量
whos %显示更多细节

v=priceY(1:10) %将priceY的前十个元素加载

save hello.mat
save hello.txt v-ascii

A(2,:) % " : " means every element along that row or column
A(:,2) % the second column of A
A([1 3],:) % get all the element along that row or column = get first row and thrid row (all columns)
A(:,2)=[10;11;12] %给第二行赋值
A=[A,[10;11;12]] % append another column vector
A(:) % put all elements of A into a single vector

A=[1 2; 3 4; 5 6]
B=[11 12; 13 14; 15 16]

C=[A;B] %将B的元素放在A的元素后行
C=[A B] %将A和B合在一起

Computing on Data
A=[1 2; 3 4; 5 6]
B=[11 12; 13 14; 15 16]
C=[1 1 ; 2 2]
A*C
A.*B % " . " means element-wise operation
A.^2

V=[1 ; 2 ; 3]
1./V
log(V) % element-wise 表示对每一个元素取其对数
exp(V) % element-wise 表示对每一个元素取其自然指数

abs(A) % 表示对A的每一个元素取绝对值
-V % -1*V
V+ones(length(V),1) % V的每一个元素加一
V+1 % V的每一个元素加一 means to add one element-wise each of my elements of V

ones(3) % 三行三列方阵
ones(3,1) % 三行一列矩阵

A' % A的转置

a=[1 15 2 0.5];
val=max(a) % a的最大值
[val,ind]=max(a) % ind代表下标
max(A)
A
a
a<3 % 比3小的显示true,比3大的显示false
find(a<3) % 找比3小的下标

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐


所有评论(0)