vectorization - How to vectorize this Matlab loop -


i need vectorize following operation since i'm little confused.

so, have m-by-2 matrix a , n-by-1 vector b. want create n-by-1 vector c entries should values of second column of a line given line correspondent value of b fall...

not sure if clear enough. anyway, code below compute c correctly can understand desired output. however, want vectorize function since real n , m in order of many thousands.

note values of bare non-integer , not equal of in first column of a (these ones non-integers too!).

m = 5; n = 10;  = [(0:m-1)*1.1;rand(1,m)]' b = (m-1)*rand(n,1)  [bincounts, ind] = histc(b,a(:,1))  = 1:n     c(i) = a(ind(i),2); end 

all need is:

c = a(ind,2); 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -