misbehave of find function

조회 수: 8 (최근 30일)
Eng. Fredius Magige
Eng. Fredius Magige 2015년 10월 1일
답변: Eng. Fredius Magige 2015년 10월 4일
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
Star Strider
Star Strider 2015년 10월 1일
You need to post your data (or sample data), what you want as output, and the relevant parts of your code.

댓글을 달려면 로그인하십시오.

채택된 답변

Eng. Fredius Magige
Eng. Fredius Magige 2015년 10월 4일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Periodic Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by