MATLAB: How to print a cell array with vectors of different length to an ascii file

cell array to txt file

I have a 1×7 cell array full of cell arrays of different length. I would like to export each of these to a .txt file, with each of the cell arrays within 1×7 columns as it's own vector.
If you could please give me assistance in this I'd much appreciate it.
thanks

Best Answer

Here is an example, assuming that a white space as separator is fine for you and that you want to write these vectors in the file as row vectors with one vector per line.
C = {[1 2 3], [4], [5 6], [7 8 9 10]} ;
fid = fopen( 'myFile.txt', 'w' ) ;
for cId = 1 : numel( C )
fprintf( fid, '%f ', C{cId} ) ;
fprintf( fid, '\r\n' ) ;
end
fclose( fid ) ;