How to change a range of numbers in a matrix to a random number of a matrix?
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Voss
2023-2-23
G = reshape(1:125,[25,5])
x = setdiff(0:24, 2:25)
idx = G >= 2 & G <= 25;
G(idx) = x(randi(numel(x),[nnz(idx),1]))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!