Find zeros in a part of a matrix

3 ビュー (過去 30 日間)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2017 年 11 月 28 日
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.

採用された回答

Jos (10584)
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
  1 件のコメント
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2017 年 11 月 28 日
It works nicely thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by