matlab - How to merge elements in a matrix -


x = [1 2 3 4 5      1 2 3 0 0]; 

i want off zeros , merge 2 rows

newx = x(:,1) + x(:,2)(nonzeros)      = [1 2 3 4 5 1 2 3]; 

nonzeros give nonzeros in column vector, have orient original matrix , transpose row vector (if that's want):

>> newx = nonzeros(x.').' newx =     1   2   3   4   5   1   2   3 

Comments

Popular posts from this blog

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -

ios - Align baselines with characters in large line heights with Text Kit -