Find zeros in a part of a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have a matrix such that:
Tarr =
1.0e+05 *
0.0006 0.0000 0.0000 0.0000 0
0.0002 0 0 0 0
0.0001 0 0 0 0.0001
0.0004 0 0 0 0
0 1.3018 1.4506 0.2323 0.0540
0.0005 0.0000 0.0000 0 0
0.0002 0 0 0 0
0.0000 0 0 0 0
0.0004 0 0 0 0
0 -2.9018 -3.0506 0.2323 0.0540
0.0005 0 0 0 0
0.0002 0 0 0 0
0.0000 0 0 0 0
0.0004 0 0 0 0
0 0 0 0.2323 0.0540
I would like to find the indices of the zero elements in the following subsection of the matrix
Tarr(5:5:end,2:end)
An then replace those with some numbers I desire. I know this must be fairly easy, however I cant seem to be able to find a straightforward way.
KR,
KMT.
0 个评论
采纳的回答
Jos (10584)
2017-11-28
temp = Tarr(5:5:end,2:end) ; % get the relevant portion
temp(temp==0) == 12345 ; % your value
Tarr(5:5:end,2:end) = temp ; % put the edited portion back in
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!