Append to exisintg file column-wise, different number of rows, don't add NaNs

2 views (last 30 days)
I'm trying to append a table column-wise (with specific column names, so not a matrix) to an existing TXT. The existing file has fewer rows than the appended dataset. I don't want a bunch of NaNs to be added to square-out the dimensions. (The number of rows and columns is much bigger than in this example, so the NaNs actually add a bunch of space and load time.) My code attemp is below, annotated with where I am stuck. Thanks for any help
data = rand(100,2);
data = array2table(data);
% I have a pre-determined list of column names for this table; code skipped here for simplicity
writetable(data, 'myExistingTable.txt');
data2append = rand(250,6);
data2append = array2table(data2append);
% I have a pre-determined list of column names for this table; code skipped here for simplicity
fid001 = fopen('myExistingTable.txt','a');
% below isn't right
fprintf(fid001,'%f %f %f %f %f %f',data2append);
fclose all;

Answers (0)

Categories

Find more on Tables 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!