Find in matlab
March 25, 2010 Leave a comment
suppose you want to select the upper triangle matrix of M and put it in a vector v
[m n] = size(M);
idx = triu(ones(m),1);
v = M(find(idx==1));
A fast version would be
v = M(logical(idx==1));
March 25, 2010 Leave a comment
suppose you want to select the upper triangle matrix of M and put it in a vector v
[m n] = size(M);
idx = triu(ones(m),1);
v = M(find(idx==1));
A fast version would be
v = M(logical(idx==1));