MATLAB: Restructure cell array from textscan

textscan cell arrays large file size

Hi folks, I'm using textscan to bring in data from a .csv file to turn it into a cell array. The cell array consists of one row with multiple columns, each containing one row with its own {M x N} cell in it. (i.e., each column in my .csv dataset gets compressed into its own cell).
C =
Columns 1 through 3
{5x1 cell} {5x1 cell} {5x1 cell}
Is there a way to instead generate a cell array with a single column and multiple rows, each row containing one row of data from my .csv file? (i.e., each row in my .csv dataset gets compressed into its own cell). Tying to get it to look like this (if its even possible):
C =
{3x1 cell}
{3x1 cell}
{3x1 cell}
{3x1 cell}
{3x1 cell}
Reason being is I'm bringing in a large number of very large .csv files, concatenating them and exporting as a tab-delimited .txt file using fprintf. Due to memory limitations, I can only import one file at a time to write to the output file.
Thanks!

Best Answer

Some testdata:
C = {};
for i1 = 1:3
for i2 = 1:5
C{i1}{i2} = i1*10+i2;
end
end
Now the conversion:
CC = num2cell(cat(1, C{:}), 1)
Maybe you want to transpose CC. But is this really useful?
Reason being is I'm bringing in a large number of very large .csv files,
concatenating them and exporting as a tab-delimited .txt file using fprintf.
It seems to be much easier to import the files as text, use strrep to replace the commas by tabs and append the result as string. The conversion and reshaping of cells is most likely a waste of time.
Related Question