Matlab中可以给矩阵里一些单个点赋值的函数

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
integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64

摘抄于help文档,有进一步理解时再补充

原文地址:https://www.cnblogs.com/Dontstop/p/5241066.html