how to insert diganole of zeros in to matrix without using loops ?
2 次查看(过去 30 天)
显示 更早的评论
my question is simple how to change the main diagonel of nXn of random numers and change the main diagonle to zeroes ?
without using loops ?
0 个评论
采纳的回答
madhan ravi
2019-3-3
a(logical(eye(size(a,1))))=0 % where a is your matrix
2 个评论
madhan ravi
2019-3-3
编辑:madhan ravi
2019-3-3
logical indexing
Alternative (faster):
a(1:size(a,1)+1:end)=0
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!