MATLAB: Get same column of matrix automatically. column I want to get same column 'automatically'. example, A = [ 1 2 3 4 5] 1X5 B = [ 3 4 2 ] 1X3 I want to get 1X10 matrixs of A,B. (regardless of value) outcome, A = [ 1 2 3 4 5 0 0 0 0 0 ] B = [ 3 4 2 0 0 0 0 0 0 0 ] Best Answer function resized = expandcolumns(m, c) %m a 1d or 2d matrix with less than c columns %c the number of columns to expand to. Additional columns are filled with 0. %input checking validateattributes(m, {'numeric', 'logical'}, {'2d'}, 1); validateattributes(c, {'numeric'}, {'scalar', 'positive'}, 2); if size(m, 2) > c error('matrix is already wider than requested'); end %the resizing: resized = [m zeros(size(m, 1), c-size(m, 2))]; end Related SolutionsMATLAB: If i have tow matrix how to crossover of them R = repmat(randi([0,1],4,1),1,4);C1 = A.*R+B.*(1-R);C2 = A.*(1-R)+B.*R; MATLAB: How to remove rows and columns in cell array Where C is your cell array:C(25419:29317,:) = [];You could also detect those rows automatically:X = all(cellfun(@isempty,C),2);C(X,:) = [] Related QuestionHow to do this on matrix to change they lookSimple Matrix Reduction Question. Ones and Zeros.How to merge tow matrixIf i have two matrix in different size how can i subtract it By adding zeros row or column ?How to add ones to binary matrix with condition to add them
Best Answer