MATLAB: Finding non-zero 2-D array arrays If I have following type of 2-D array which can have entire row of zero's 1 3 7 3 6 9 0 0 0 2 3 8 I want following output array: 1 3 7 3 6 9 2 3 8 Can someone please help? Best Answer a=[1 3 7; 3 6 9; 0 0 0;2 3 8];b=a(~all(a==0,2),:); Related SolutionsMATLAB: Finding and Storing element row-wise when the matrix has SYM. A=[1 0 0; 7 0 0;4 5 0;3 5 0;1 4 7; 8 2 1];nonzeros(double(reshape(A',[],1))) ^^^^^^----converts to a double from sym or just use vpa (does the same work as double) Gives:ans = 1 7 4 5 3 5 1 4 7 8 2 1 MATLAB: Dear all:I have a 6* 3 matrix. I wanna choose 4rows randomly. how can I selecete all array in a rows randomly without replacement A=[1 2 3;2 3 5;6 4 1;8 6 0;2 4 1;1 4 7;8 4 2]B=A(randperm(6,4),:) Related QuestionFor elements in two arrays/columns of numbers, how can I find the average only if both elements are non-zeroHow to do element by element comparisonHow can I delete some rows from 2-D arrayHow to remove zeros from the matrixHow to make a matrix mirror another
Best Answer