日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MATLAB中求矩阵非零元的坐标

發布時間:2023/12/4 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MATLAB中求矩阵非零元的坐标 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MATLAB中求矩陣非零元的坐標:

方法1:

index=find(a); [i,j]=ind2sub(size(a),index); disp([i,j])

?

方法2:

[i,j]=find(a>0|a<0) %列出所有非零元的坐標 [i,j]=find(a==k) %找出等于k值的矩陣元素的坐標

?

所用函數簡介:

IND2SUB Multiple subscripts from linear index.

IND2SUB is used to determine the equivalent subscript values
corresponding to a given single index into an array.

[I,J] = IND2SUB(SIZ,IND) returns the arrays I and J containing the
equivalent row and column subscripts corresponding to the index
matrix IND for a matrix of size SIZ.
For matrices, [I,J] = IND2SUB(SIZE(A),FIND(A>5)) returns the same
values as [I,J] = FIND(A>5).

[I1,I2,I3,...,In] = IND2SUB(SIZ,IND) returns N subscript arrays
I1,I2,..,In containing the equivalent N-D array subscripts
equivalent to IND for an array of size SIZ.

Class support for input IND:
float: double, single

See also sub2ind, find.

?

FIND Find indices of nonzero elements.

I = FIND(X) returns the linear indices corresponding to
the nonzero entries of the array X. X may be a logical expression.
Use IND2SUB(SIZE(X),I) to calculate multiple subscripts from
the linear indices I.

I = FIND(X,K) returns at most the first K indices corresponding to
the nonzero entries of the array X. K must be a positive integer,
but can be of any numeric type.

I = FIND(X,K,'first') is the same as I = FIND(X,K).

I = FIND(X,K,'last') returns at most the last K indices corresponding
to the nonzero entries of the array X.

[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.

[I,J,V] = FIND(X,...) also returns a vector V containing the values
that correspond to the row and column indices I and J.

Example:
A = magic(3)
find(A > 5)

finds the linear indices of the 4 entries of the matrix A that are
greater than 5.

[rows,cols,vals] = find(speye(5))

finds the row and column indices and nonzero values of the 5-by-5
sparse identity matrix.

See also sparse, ind2sub, relop, nonzeros.

Overloaded methods:
codistributed/find

?

SUB2IND Linear index from multiple subscripts.

SUB2IND is used to determine the equivalent single index
corresponding to a given set of subscript values.

IND = SUB2IND(SIZ,I,J) returns the linear index equivalent to the
row and column subscripts in the arrays I and J for a matrix of
size SIZ.

IND = SUB2IND(SIZ,I1,I2,...,IN) returns the linear index
equivalent to the N subscripts in the arrays I1,I2,...,IN for an
array of size SIZ.

I1,I2,...,IN must have the same size, and IND will have the same size
as I1,I2,...,IN. For an array A, if IND = SUB2IND(SIZE(A),I1,...,IN)),
then A(IND(k))=A(I1(k),...,IN(k)) for all k.

Class support for inputs I,J:
float: double, single

See also ind2sub.



來自:http://zhidao.baidu.com/link?url=imuLeLDv16Bsg-xcu4O1M8hVzjdCiRfq6PYHu4MR-o1q9AeMWy-UM3AdZTA7av9k1WLExeyYPVDumS46TNNr1q

總結

以上是生活随笔為你收集整理的MATLAB中求矩阵非零元的坐标的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。