filling a internal value of a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi I have the following matrix
I=
0 1 0 0
0 0 1 1
0 1 0 0
0 0 1 0
I want the following output:
0 1 0 0
0 1 1 1
0 1 1 0
0 0 1 0
Is there any easy way to do that,easily?
Thanks
0 个评论
采纳的回答
Matt Fig
2011-6-26
I=[0 1 0 0
0 0 1 1
0 1 0 0
1 0 0 0
0 0 1 0
1 0 0 0
0 0 1 0];
idx = findsubmat(I,[1 0 1]'); % Available at the above link...
I(idx+1) = 1
I =
0 1 0 0
0 1 1 1
0 1 0 0
1 0 0 0
1 0 1 0
1 0 1 0
0 0 1 0
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!