Version (1.78 KB) by Diederick
Merges contents of multiple cell arrays into one big cell array, with expansion
Updated 2 Feb 2012

View License

MergeCell takes any number of cell vectors (contain the same datatype) and concatenates their contents into one big cellvector
Any signleton inputs are expanded as needed, these inputs can be 1x1 cells or the contained datatype itself

Example: To add some information about fit to plot legend, we'd wan't to append information about the fit to the line labels:

linelbls = {'line a','line b','line c'};
slope = [.9 1 4.2];
slopetxt= arrayfun(@(x) sprintf('%.3f',x),slope,'UniformOutput',false);

leglbls = MergeCell(linelbls,', slope: ',slopetxt);
% leglbls = MergeCell(linelbls,{', slope: '},slopetxt); would be equivalent

Cite As

Diederick (2024). MergeCell (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Data Type Conversion in Help Center and MATLAB Answers
Tags Add Tags

Inspired: Yahoo! Finance Data Loader

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

fixed some typos in the example