简体   繁体   中英

How to find the elements of a matrix > 0 in Matlab?

我很好奇-是否有单个Matlab命令返回Matrix中大于0的元素?

The following code returns all positive elements of matrix A :

A(find(A > 0))

or in short form as proposed by Gunther Struyf:

A(A > 0)

The find function will return the indices of elements that are not zero.

ind = find(A > 0);

is what you're looking for...

或为此目的专门设计的命令:“ nonzeros”

nz_A = nonzeros(A);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM