matlab_find命令


matlab的find 和 size

matlab的一些小tip

1,索引从1开始。

2,没有python中 x.方法 的用法

3,矩阵 数组 的索引都用小括号()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

%
% This MATLAB function returns a vector containing the linear indices of % each nonzero element in array X.
%
% k = find(X)
% k = find(X,n)
% k = find(X,n,direction)
% [row,col] = find(___)
% [row,col,v] = find(___)

>>x=[1 2 3 1 2 3]
x =

1 2 3 1 2 3
>>y=find(x==1)
y =

1 4
>>x(y)
ans =

1 1
>>B=reshape(x,2,3)
B =

1 3 2
2 1 3
>> [row,col]=find(B==1)
row =

1
2


col =

1
2

size

This MATLAB function returns a row vector whose elements contain the length of
the corresponding dimension of A.

1
2
3
4
sz = size(A)
szdim = size(A,dim)
[m,n] = size(A)
[sz1,...,szN] = size(A)