some note about everything
- npm是node.js 的一个包管理器
- windows cmd 下切换目录时不能直接切换驱动器,比如说
cd D:\
是不对的, 直接是D:
就可以换到D盘,或者是cd /d D:
也可以 MATLAB find 函数
[I,J] = find(X,…) returns the row and column indices instead of
linear indices into X. This syntax is especially useful when working
with sparse matrices. If X is an N-dimensional array where N > 2, then
J is a linear index over the N-1 trailing dimensions of X.(对于N-1维来说是线性索引)把N-1 维压扁 ==!
1 | x=rand(4,4,4) |
把第二维压扁数是第14 个,还有另一种最好的方法就是ind2sub
1 | %求一个三维矩阵最大值的坐标: |
MATLAB max min 函数
For vectors, max(X) is the largest element in X. For matrices,
max(X) is a row vector containing the maximum element from each
column. For N-D arrays, max(X) operates along the first
non-singleton dimension.
矩阵的第一个尺寸不是1的维,比如说a=242 第一个尺寸不是1的维就是第一维。
1 | >> a=rand(2,2,2) |
正常的sum也是按照这个原理,第一个尺寸不是1的维是行,所以是按行加,max min 也是同理
max(a,[],1)%从第一维中寻找最大值 等价于 max(a) 找到的最大值是一个行(助记)
max(a,[],2)%从第二维中寻找最大值
[Y,I]=max(a,[],2) Y返回一列数,分别是每行的最大值(假设a是2*2),I返回的是索引,不过I中存的是列数,即对应的最大值是在第几列。
repmat 函数
1.B = repmat(A,n) returns an array containing n copies of A in the row and column dimensions. The size of B is size(A)*n when A is a matrix.
2.B = repmat(A,r1,…,rN) specifies a list of scalars, r1,..,rN, that describes how copies of A are arranged in each dimension. When A has N dimensions, the size of B is size(A).*[r1…rN]. For example, repmat([1 2; 3 4],2,3) returns a 4-by-6 matrix.
3.B = repmat(A,r) specifies the repetition scheme with row vector r. For example, repmat(A,[2 3]) returns the same result as repmat(A,2,3).
复制矩阵A
- 求每一行的最大值,并且将不是最大值的元素设为0,保留最大值。
[Y,I] = max(A, [], 2);
B = zeros(size(A));
B(sub2ind(size(A), 1:length(I), I’)) = Y;
将空值设为0
B(isnan(B)) = 0
bsxfun 函数的强大功能