cf.
http://neural.cs.nthu.edu.tw/jang/books/matlabProgramming4beginner/cdrom/matlabProgramming4beginner/slide/
# command-line mode: similar to bash emacs mode
C-P/N navigate in the command history
C-A/E start/end of line
C-B/F backward/forward
C-U kill the line (not kill to the start)
C-K kill to the end of line
C-R search
C-H/D backspace/delete
# external
!cmd
[status, result] = UNIX('cmd')
getenv('name')
# example
!which plot # search "plot" in $PATH
which plot # the location of file/function "plot"
# round
round, ceil, floor
# timer
tic
...
toc
# string
strcmp(A, B [,n]) % 字符串比较 (前n个字符)
strmatch('substr', StrMatrix) % 匹配测试
findstr('string', 'substr') % 子串查找
strrep('string', 'sub', 'rep') % 子串替换
# special matrix
zeros(2, 3) # all 0
ones(1, 3) # all 1
eye(3) # elementary
linspace(x0, xN, npoints) # default: npoints = 100
reshape, repmat, diag
upper, lower
svd
# matrix, vector
size, length
det, norm
rank
sum
mean # average
var # variance
std # std. deviation
max/min
inv(X) # inverse matrix
eig(X) # vector of eigenvalues
[V, D] = eig(X) # X V = V D
# matrix function
sqrtm, expm, logm
find(A gt 0)
eq(A,B) neq lt le gt ge
all any exist
for i=1:7
i
end
if (i gt 0)
positive
elseif i lt 0
negative
else
0
end
while (i gt 0)
..
end
function [out1, out2] = myfunction(input1, input2)
# plot
figure # new figure
axis([xmin xmax ymin ymax])
axis equal/normal/image
xlabel('radians')
ylabel('sin value')
title('dummy')
legend('sin', 'cos')
subplot(m, n, c); # mxn, c is the current
hold on/off
grid on/off
box on/off
plot
loglog
semilogx
semilogy
plotyy # double-y
fplot('function', [xmin, xmax])
polar(theta, r)
# color
b: blue
g: green
k: black
r: red
w: white
2008-03-12
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment