Be the first to rate this file! 8 Downloads (last 30 days) File Size: 1.77 KB File ID: #30780

mergecell

by

 

Appends cell arrays together along the dimension of your choosing (limited to 2d cell arrays).

| Watch this File

File Information
Description

% 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

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us