Hi suppose I have a 100×3 matrix representing coordinates in xyz plane. I use an if loop to select particles with a certain x value and y value and create a new matrix.
Eg:
for i=1:length(matrix) if matrix(i,1)>100 & matrix(i,1)<400 & matrix(i,2)>100 & matrix(i,2)<400 matrix_new(i,1)=matrix(i,1); matrix_new(i,2)=matrix(i,2); matrix_new(i,3)=matrix(i,3); endend
The new matrix I get has zeros for the conditions that are false. How can I modify this condition so that I get a matrix without zeros.
Thanks
Best Answer