Matlab: 新学到的函数

unique

>> A = [9 2 9 5];
>> [C, ia, ic] = unique(A) 
%Find the unique values of A and the index vectors ia and ic, such that C = A(ia) and A = C(ic).

C =

     2     5     9


ia =

     2
     4
     1


ic =

     3
     1
     3
     2

ismember

>> A = [5 3 4 2];B = [2 4 4 4 6 8];

>> Lia = ismember(A,B)
%Determine which elements of A are also in B.
Lia =

     0     0     1     1

find

>> X = [3 2 0; -5 0 7; 0 0 1]

X =

     3     2     0
    -5     0     7
     0     0     1

>> [row,col,v] = find(X)
%Find the nonzero elements in a 3-by-3 matrix. Specify three outputs to return the row subscripts, column subscripts, and element values.
row =

     1
     2
     1
     2
     3


col =

     1
     1
     2
     3
     3


v =

     3
    -5
     2
     7
     1

intersect

>> A = [7 1 7 7 4]; B = [7 0 4 4 0 5];
>> C = intersect(A,B)
%Find the values common to both A and B.
C =

     4     7
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值