find is working in strange way

2 views (last 30 days)
Hello I am trying to use the find to find number in array greater than 0.6 , but the behavior is strange
cluster_map=zeros(21,14);
[r c]=find(field>=0.6)
the length of the r is 20
cluster_map(r,c)=2;
[rr cc]=find(cluster_map == 2);
the length of rr is 40 !!! how this happen. I have attached the field array. thanks in advance

Accepted Answer

Sean de Wolski
Sean de Wolski on 20 Mar 2014
r = [1 5 8]
c = [2 3 6]
x = zeros(10)
x(r,c) = 1
I'd guess what you want is to use sub2ind to use each combo of r and c once
x = zeros(10);
x(sub2ind(size(x),r,c)) = 1
  6 Comments
ahmed shaaban
ahmed shaaban on 20 Mar 2014
it just fill x(r,c,1) , but still x(r,c,2). it looks like one need to do something like that
x(sub2ind(size(x),r,c,[1 1 1]))=3
x(sub2ind(size(x),r,c,[2 2 2]))=3
I donot know how to do that once.
ahmed shaaban
ahmed shaaban on 20 Mar 2014
May be something like that
for (i=1:2);x(sub2ind(size(x),r,c,[i i i]))=3;end

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!