matlab - Identify if a column is repeated sequentially N times in a Matrix -



matlab - Identify if a column is repeated sequentially N times in a Matrix -

i know question has been asked in different way:

matlab: identify if value repeated sequentially n times in vector

i wondering how can follow upper link if dealing matrix coordinates, like: m = [ x1 x2 x3 x4 ... xn; y1 y2 y3 y4 ... yn]

for illustration n= 3 times:

m= [ 2 3 3 3 1 4 4 4 6 6 6 6 8; 1 2 2 7 9 5 5 5 4 4 3 3 2] ans: [ 4 4 4; 5 5 5] @ position 6

i looking finding column has been repeated 3 times "sequentially". in mentioned link there way vector.

try this

k = size(m,1); %// fg matrix sum of differences of n continuous columns\ fg = conv2(diff(m'),ones(k,n-1))'; %// coll row vector column indices fg 0 [roww coll] = find(fg(k:size(fg,1)-k+1,n-1:end - n) == 0); %// out_cell cell entries required matrices out_ = arrayfun(@(x)(m(:,x:x+n-1)),coll,'uniformoutput',0);

out_ cell containing matrices size k x n columns have occurred n times simultaneously

matlab matrix

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -