Borrar filtros
Borrar filtros

Connecting like numbers in a matrix

2 visualizaciones (últimos 30 días)
Harold
Harold el 15 de Mzo. de 2013
Suppose I have a matrix of the following data:
data = [6, 5, 3, 0, 0, 1; ...
0, 0, 0, 0, 0, 2; ...
0, 0, 0, 0, 0, 4; ...
0, 0, 0, 0, 0, 0; ...
6, 0, 0, 0, 0, 0; ...
5, 0, 4, 0, 0, 0]
What I would like to do is find the like entries that I can connect directly to by remaining on the edges of the matrix. So for instance, after applying this function I should get
newdata = [6, 5, 3, 0, 0, 1; ...
6, 0, 0, 0, 0, 2; ...
6, 0, 0, 0, 0, 4; ...
6, 0, 0, 0, 0, 4; ...
6, 0, 0, 0, 0, 4; ...
5, 0, 4, 4, 4, 4]
  2 comentarios
Cedric
Cedric el 15 de Mzo. de 2013
Editada: Cedric el 15 de Mzo. de 2013
Look at what you get when you run the following:
for ii = 1 : size(data,1)
data(ii, end)
end
now you could exploit this approach to follow "edges" of your matrix and maybe update its elements.
Harold
Harold el 15 de Mzo. de 2013
Ok, I will try this out. I will have to think about the structure some more since I will have to start at some nonzero value on an edge and work my way around until I reach another entry with the same value, whilst making sure any values I "pass" through are zero.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by