MATLAB: Delete zero elements from vector matrices Hi I have k (1,600) size, it contain zeros at 451-600 elements. I want to delete these zero elements. At the end of this vector i want to add two elements with value equal to the last element . thank you in advance Best Answer k = nonzeros(k);k(end+1:end+2) = k(end) Related SolutionsMATLAB: The minimum value of a matrix array and its index A = rand(1,5); %example matrix[mini,index] = min(A) %mini= minimum value, index = index of minimum valueorA = rand(5) %example 5x5 matrix[minRow,indexRow]=min(A)[minCol,indexCol]=min(minRow)index = [indexRow(indexCol) indexCol] %minimum value o 5x5 matrix (row index, column index)or can use: (https://es.mathworks.com/help/matlab/ref/min.html)A = rand(5)[M,I] = min(A(:));[I_row, I_col] = ind2sub(size(A),I);index = [I_row I_col] MATLAB: How to convert and display numbers into strings for k=1:1000 if k<10 tmp_str = 'K=000'; elseif k<100 tmp_str = 'K=00'; elseif k>=100 && k<1000 tmp_str = 'K=0'; else tmp_str = 'K='; end [tmp_str num2str(k)]end Related QuestionRandom matrix with maximum values.Matrix Function to Finite Element MethodHow to create a two columns cell array from two different cellsExtending an array for zero padding,How to create a vector
Best Answer