mergecell

Version 1.0.0.0 (1.77 KB) by Jeremy
Appends cell arrays together along the dimension of your choosing (limited to 2d cell arrays).
304 Downloads
Updated 16 Mar 2011

View License

% OUT = MERGECELL(IN1,IN2,...INx,DIM)
%
% MERGECELL simply merges cell arrays (IN1,IN2,...,INx) together by
% appending them along the DIM dimension. There is no requirement that the
% input cell arrays have similar dimensions. The result is a cell array
% large enough to accomodate the sizes of each input array with blanks
% filling the empty spots.
%
% Example:
%
% a{1} = {'a','b','c','d','e'};
% a{2} = {'f';'g';'h'}; %-- Notice these are different orientations
%
% out = mergecell(a{:},1)
%
% returns: 'a' 'b' 'c' 'd' 'e' 'f'
% [] [] [] [] [] 'g'
% [] [] [] [] [] 'h'
%
%
% out = mergecell(a{:},2)
%
% returns: 'a' 'b' 'c' 'd' 'e'
% 'f' [] [] [] []
% 'g' [] [] [] []
% 'h' [] [] [] []
%
%
% out = mergecell(a{1},a{2}',1)
%
% returns: 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h'
%
%
% Copyright (C) 2011 Jeremy Brower.
% jeremy.brower@gmail.com

Cite As

Jeremy (2024). mergecell (https://www.mathworks.com/matlabcentral/fileexchange/30780-mergecell), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Cell Arrays in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0