octave - JasonWayne/personal-wiki GitHub Wiki
Ng的ML新版课程的视频
作为octave/matlab的reference
# 数学函数
ln(b) # matlab
log(b) # octave
log10()
log2()
exp()
sqrt()
nthroot(b, n)
% 两种生成数列的方式
a = 1 : 0.5 : 10
a = linspace(1, 10, 20)
% 作图基础
plot(x, y, 'r--\*' or 'g-' or 'm:s')
xlabel('x')
ylabel('sin(x)')
title('test plot')
legend('f(x) = sin(x)')
% 取矩阵中元素
a = M(3,2)
a = M([2, 3], 2)
a = M(2 : 4, 2)
a = M(:, 2)
l1 = length(v)
l2 = length(matrix)
s = size(m)
% concatenate
C = [A, B]
C = [A; B]
% &: and, |: or, ~=: not equal to
v = [1,0,0.01, 2, 0.04]
I = v < 0.05
% I = [0, 1, 1, 0, 1]
a = v[I]
% a = [0, 0,01, 0.04]
v[I] = 0
% --> v = [1, 0, 0, 2, 0]
% if
if x < 0
f = 1 - x
else
f = 2 * x
end
% for
for x = 1 : 6
y(n + 1) = y(n) - 0.1 * y(n)
end
% while
while 1
x = 1
end
Array Creation Functions: rand, ones, eye, randi, randn, zeros, toeplitz, vander, diag, magic, hilb
randi([0, 2], 3, 4): Random Integers between 0 and 2
randn(): normally distributed VS. rand(): uniformly distributed
一些数学符号及其对应的英语
superscript(式中的2就是superscript): $ a^2 $ Closing Parenthesis ) Opening Square Bracket [ Opening Curse Brace { hyphen - Numerator Denominator
BackSlash
Caret ^
Dot .
Pipe symbol |
Question mark ?
Asterisk *
Opeining parenthesis (