Octave - compare matrix's columns with vector -


i have matrix , vector , want compare each column of matrix vector - want number of column equal vector. example:

matrix m=1 1 0 1          1 0 0 0          0 1 1 0  vector v= 1 0 1 

the result should 2 (since second column of m equal vector v)

how do that?

octave> m = [1 1 0 1; 1 0 0 0; 0 1 1 0]; octave> v = [1 0 1]; octave> sum(m == repmat(v', 1, 4)) ans =     1   3   2   2  octave> sum(m == repmat(v', 1, 4)) == size(m, 1) ans =     0   1   0   0  octave> find(sum(m == repmat(v', 1, 4)) == size(m, 1)) ans =  2 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -