Concatenate different sizes Cell Matrix

Version 1.0.0.0 (1.35 KB) by Francesco
Concatene cell matrix (row-wise or column-wise) regardless of the different sizes
117 Downloads
Updated 13 May 2015

View License

% Concatene cell matrix (row-wise or column-wise) regardless of the different sizes, filling the missing cells with NaN.
% This function generalize previous functions "K_cRows" and "K_cCols".
%
% c=K_cCells(b,a,'row') or c=K_cCells(b,a) or c=K_cCells(b,a,"everyCharOrNumber") for row-wise;
% c=K_cCells(b,a,'col') for column-wise;

A={'a11' 'a12';'a21' 'a22'}

A =

'a11' 'a12'
'a21' 'a22'

>> B={'b11' 'b12' 'b13'; 'b21' 'b22' 'b32'; 'b31' 'b32' 'b33'}

B =

'b11' 'b12' 'b13'
'b21' 'b22' 'b32'
'b31' 'b32' 'b33'

>> C=K_cCells(A,B)

C =

'a11' 'a12' []
'a21' 'a22' [ ]
'b11' 'b12' 'b13'
'b21' 'b22' 'b32'
'b31' 'b32' 'b33'

>> C=K_cCells(A,B,'col')

C =

'a11' 'a12' 'b11' 'b12' 'b13'
'a21' 'a22' 'b21' 'b22' 'b32'
[ ] [ ] 'b31' 'b32' 'b33'

Cite As

Francesco (2024). Concatenate different sizes Cell Matrix (https://www.mathworks.com/matlabcentral/fileexchange/50832-concatenate-different-sizes-cell-matrix), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Creating and Concatenating Matrices in Help Center and MATLAB Answers
Tags Add Tags
Acknowledgements

Inspired: gold spot

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