I am trying to make a zeros matrix where certain places is replaced by a 1
1 次查看(过去 30 天)
显示 更早的评论
I have created a 3x8 matrix of zeroes where i am trying to get place (1,1) and (1,8) and (3,4) to be replaced by ones. so it would look like this:
1 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0
i have tried to wrote some code for this but i couldn't get it to work.
i have trid this:
b=zeros(3,8)
b([1,3],[1,4,8])=1
but this gives me a matrix that looks like this:
1 0 0 1 0 0 0 1
0 0 0 0 0 0 0 0
1 0 0 1 0 0 0 1
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 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!