How to concatenate cells in mat file under each other?

1 view (last 30 days)
Hello, I have a .mat file which is comprised of 255 cells. Each cell is a 14 by 65 table. I need to concatenate the tables under each other so that I can have a 14*225 by 65 table at the end. Does anyone know how I can do so in Matlab?

Accepted Answer

Stephen23
Stephen23 on 11 Aug 2020
Edited: Stephen23 on 11 Aug 2020
Your question is unclear: does the mat file contain one cell array of 255 elements, or 255 separate scalar cell arrays?
If there are 255 separate scalar cell arrays and no other data in the file:
D = 'absolute/relative path to where the file is saved';
F = 'the filename.mat';
S = load(fullfile(D,F));
C = structcell(S);
T = vertcat(C{:});
If there is only one cell array of 255 elements and no other data in the file, replace struct2cell with:
C = S.nameOfTheField;

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!