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

조회 수: 2 (최근 30일)
newbie9
newbie9 2019년 2월 10일
편집: newbie9 2019년 2월 10일
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;

답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by