Replacing n random zeros in a matrix with a specific nonzero value

Suppose I start with a zero matrix
X = zeros(100)
How can I replace n random zeros in matrix X with a single nonzero value (e.g., replace 10 zero elements in the matrix X with 1)?

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Random Number Generation 的更多信息

产品

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by