From: alfann on 4 Jun 2010 05:58 Thanksss Oleg Komarov, but the problem is: The code that you built it, it works with one chain and it does not work with more than one chain. How can you fix it to work with more than one chain. See this matrix includes two chains: Example 3 (two chains) more clear: U1=[20 33 50 20 10 80 10; 10 1 85 88 90 10 90; 60 1 20 33 21 21 30; 50 05 50 44 50 50 10; 80 50 50 10 1 1 1; 20 0 50 60 1 10 50; 10 50 30 50 50 10 90; 80 20 10 70 80 50 30; 40 50 30 80 20 10 20] In this matrix, we see two chains: First chain: U1(3,2)=1 and U1(2,2)=1 second chain: U1(6,5)=1 and U1(5,5)=1 and U1(5,6)=1 and U1(5,7)=1 now, I want calculate the summation of the neighbors of ones, and it will be: For first chain: average=(5+60+10+33+85+20)/6; and For second chain: average=(50+60+10+50+50+10+50+10)/8 Then the U1 matrix becomes: U1=[20 33 50 20 10 80 10; 10 35.5 85 88 90 10 90; 60 35.5 20 33 21 21 30; 50 05 50 44 50 50 10; 80 50 50 10 36.25 36.25 36.25; 20 0 50 60 36.25 10 50; 10 50 30 50 50 10 90; 80 20 10 70 80 50 30; 40 50 30 80 20 10 20]
From: Oleg Komarov on 4 Jun 2010 10:53 alfann <alfann.net(a)hotmail.com> wrote in message <1137948566.279085.1275659955694.JavaMail.root(a)gallium.mathforum.org>... > Thanksss Oleg Komarov, > but > the problem is: > The code that you built it, it works with one chain and it does not work with more than one chain. > How can you fix it to work with more than one chain. yes indeed, you can use the 'islands' function in order to find all the chains and then modify my solution in order to consider each chain separately. islands: http://www.mathworks.com/matlabcentral/fileexchange/21376 % Isolate chains giving them a different index [a,b] = islands(U1); b(b(:,end) ~= 1,:) = []; a(~ismember(a,b(:,1))) = 0; Now you can work on each separate chain with my algorithm...you can use a loop (easier to adapt) or vectorize the code. Oleg
From: alfann on 4 Jun 2010 07:50 I downloaded it but I do not know where I must put it in? Which folder? Could you please help me?
From: dpb on 4 Jun 2010 12:07 alfann wrote: > I downloaded it but I do not know where I must put it in? > Which folder? Any one on the matlab path altho I would suggest creating one specifically for such additional downloaded FEX contributions. Certainly don't put it in a TMW-updated one... --
From: alfann on 4 Jun 2010 08:47 Sorrrry for that, but I copied the file which I downliaded it and put it in my matlab path then I used the code that you gave me but I do not know how can I use it. Buceause I don't know how can I use the function and I read about it but still not understand. sorry but could you please help me to solve it because I spent long time to solve it.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Identify colors in an RGB image Next: how to randomize random binary bits |