misbehave of find function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Eng. Fredius Magige
il 1 Ott 2015
Risposto: Eng. Fredius Magige
il 4 Ott 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 Commento
Star Strider
il 1 Ott 2015
You need to post your data (or sample data), what you want as output, and the relevant parts of your code.
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!