MATLAB: Concatenate cell concatenation i have a cell (symbol {} on the variable list) with a=('kkk', 'lll', 'xxx', 'jjj.xls') and i want to concatenate a so that i can have b = ('kkk_lll_xxx_jjj.xls') thank you Best Answer a={'kkk', 'lll', 'xxx', 'jjj.xls'}';out = [a(:)';repmat({'_'},1,numel(a))];out = [out{:}];out = out(1:end-1);variant 2out = cell(1,2*numel(a)-1);out(1:2:end) = a;out(2:2:end) = {'_'};out = [out{:}]; Related SolutionsMATLAB: How to convert Cell Array index into Matrix with ones The simple way:A = {2, [2, 3], 3, [3, 4]};B = zeros(numel(A), max(cat(2, A{:}))); % Pre-allocatefor iRow = 1:numel(A) B(iRow, A{iRow}) = 1;endA vectorized way:% UNTESTEDnA = cellfun('length', A);col = cat(2, A{:});row = repelem(1:numel(A), nA);sizeB = [numel(A), max(cat(2, A{:}))];index = sub2ind(sizeB, row, col);B(index) = 1; MATLAB: Creat a cell array so that each cell contain 3D matrix of 640x480x3 A - your 3D matrixout_cells = arrayfun(@(ii)A,1:44,'un',0) Related QuestionHow to convert an array of cells into an array of structuresPre allocating triple loopsHow to unnest cell arrays using a for loop
Best Answer