matlab 找数组中非0数的行和列

http://blog.sina.com.cn/s/blog_82b526270101a1wf.html

ind = find(X)
ind = find(X, k)
ind = find(X, k, 'first')
ind = find(X, k, 'last')
[row,col] = find(X, ...)————用了这个
[row,col,v] = find(X, ...)

Description

ind = find(X) locates allnonzero elements of array X, and returns the ofthose elements in vector ind. If X isa row vector, then ind is a row vector; otherwise, ind isa column vector. If X contains no nonzero elementsor is an empty array, then ind is an empty array.

ind = find(X, k) or ind = find(X, k, 'first') returns at mostthe first k indices corresponding to the nonzeroentries of Xk must be a positiveinteger, but it can be of any numeric data type.

ind = find(X, k, 'last') returnsat most the last k indices corresponding to thenonzero entries of X.

[row,col] = find(X, ...) returnsthe row and column indices of the nonzero entries in the matrix X.This syntax is especially useful when working with sparse matrices.If X is an N-dimensional array with N > 2, col containslinear indices for the columns. For example, for a 5-by-7-by-3 array X witha nonzero element at X(4,2,3)find returns4 in row and 16 in col. Thatis, (7 columns in page 1) + (7 columns in page 2) + (2 columns inpage 3) = 16.

[row,col,v] = find(X, ...) returnsa column or row vector v of the nonzero entriesin X, as well as row and column indices. If X isa logical expression, then v is a logical array.Output v contains the non-zero elements of thelogical array obtained by evaluating the expression X

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值