misbehave of find function

1 visualización (últimos 30 días)
Eng. Fredius Magige
Eng. Fredius Magige el 1 de Oct. de 2015
Respondida: Eng. Fredius Magige el 4 de Oct. de 2015
Within a certain row of adjacent (1,0 matrix) one of it point known(as is also 1), I use it as base and looking the next one as long has 1, if not, I have to start from the initial column within that row. Unfortunately not behaving as expected. Any suggestion is welcome. Thanks all, see the input (adjacency matrix, code and output of the behaving find function:
Input file:
CON=[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0
0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0
0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1
0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0
0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0
0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0
0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0
1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
];
[r c]=size(CON);
for n=1:size(CON,1)
[rr cc]=find(CON(:,n)>0,n,'last');nn=n,rr,
[pp p]=find(CON(rr,cc+1:c)>0,1)
if(p>=1)
[rrc rcc]=find(CON(rr,cc+1:end)>0,1),
else
[rrc rcc]=find(CON(rr,1:cc-1)>0,1),
end
end
OUTPUT of find function (eg nn=2, pp=1, p=1; I meanwhile expectes p to be 2)
nn =1 rr = 16
pp =1 p = 6
rrc =1 rcc =6
nn =2 rr = 3
pp =1 p= 1
rrc =1 rcc =1
nn =3 rr = 4
pp =1 p = 2
rrc =1 rcc =2
nn =4 rr = 15
pp =1 p =1
rrc =1 rcc =1
nn =5 rr =15
pp =1 p =2
rrc =1 rcc =2
nn = 6 rr =14
pp =1 p =3
rrc =1 rcc =3
nn =7 rr =16
pp = 1 p =4
rrc =1 rcc = 4
nn = 8 rr =14
pp =1 p =5
rrc =1 rcc =5
nn = 9 rr =15
pp =3 p =3
rrc =3 rcc =3
nn =10 rr =13
pp =3 p = 3
rrc =3 rcc = 3
nn = 11 rr = 12
pp = 1 p =8
rrc =1 rcc = 8
nn =12 rr =13
pp = 2 p = 3
rrc =2 rcc =3
nn =13 rr = 12
pp =1 p =2
rrc =1 rcc =2
nn =14 rr =15
pp =4 p = 3
rrc =4 rcc =3
nn = 15 rr =14
pp =1 p = 2
rrc =1 rcc =2
nn =16 rr =7
pp = 1 p = 1
rrc = 1 rcc =1
  1 comentario
Star Strider
Star Strider el 1 de Oct. de 2015
You need to post your data (or sample data), what you want as output, and the relevant parts of your code.

Iniciar sesión para comentar.

Respuesta aceptada

Eng. Fredius Magige
Eng. Fredius Magige el 4 de Oct. de 2015
I succeed to resolve my question, "misbehaving of find function" I used and incorporate flipdim function in find (... last)function; I was endup with all previous related numerical figures; I have noted that adjacency matrix is not enough exploration in solving engineering networking challenges. Thanks Matlab team.

Más respuestas (0)

Categorías

Más información sobre Just for fun 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