MATLAB: Raise the zeros in the vector up vectors If I have a vector [5 8 0 7 9 0 3], how do I put it this way: [0 0 5 8 7 9 3] use only function if-else thank you. Best Answer Something like this,v = [5 8 0 7 9 0 3]ind = v==0;v = [v(ind) v(~ind)] Related SolutionsMATLAB: Copying specified number of elements from each row in a matrix New_Values = Values .* bsxfun(@le, (1:size(Values,2)), V(:).'); MATLAB: How to remove unwanted zeros from a vector v = [ 0 0 0 0 4 5 6 0 0 0 9 9 8 7 6 0 0 0 0 0 0 3 4 4 0 0 0];d = [1 diff(v)]; % 0's indicate when the value didn't changex = d==0 & v==0; % Indexes where value is 0 and didn't changev(x) = []; % Remove the indexes associated with x Related QuestionLongest segment of successive numbers of a sequenceHow to change a column vector into a square a matrixHow to get the sum of several sets of nonzeros in arrayHow to convert 2X4X10 array into 4x2x10 arrayRearrange an array based on a matrixHow to find zeros of a matrixCombination of multiple arrays
Best Answer