Find zeros in a part of a matrix

1 visualización (últimos 30 días)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis el 28 de Nov. de 2017
Comentada: Konstantinos Tsitsilonis el 28 de Nov. de 2017
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.

Respuesta aceptada

Jos (10584)
Jos (10584) el 28 de Nov. de 2017
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

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by