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
Post a Comment