MATLAB: All the posible combination of two matrices combination of two matrixmatrix manipulations I have two matrix A=[1] and B=[2 3 4] find the all possible combination of these tow matrices is the output C=[1 2; 1 3; 1 4; 1 2 3; 1 2 4; 1 3 4; 1 2 3 4] how to find it Best Answer C = [];for j1 = 1:numel(B) a = nchoosek(B,j1); C = [C;num2cell([repmat(A,size(a,1),1),a],2)];end Related SolutionsMATLAB: How to concatenate all the cell values horizondally in matlab One way>> cac = {[1;1;1] [2;2] [3;3;3;3] };>> cat( 1, cac{:} )'ans = 1 1 1 2 2 3 3 3 3 MATLAB: How to convert from cell array to multidimensional array A -your cell array [3 x 3].Z = cellfun(@(x)reshape(x,1,1,[]),A,'un',0);out = cell2mat(Z); Related QuestionVariables with especific posible valuesConverting cell to 3 dimensional matrixConvert cell array to 3d array
Best Answer