Removing automatic variable names in array2table or writetable and adding some text to the header of output file

3 views (last 30 days)
Mohammad R. Ghassemi
Mohammad R. Ghassemi on 17 Oct 2021
Hi, I am trying to get a text output file using the following code:
writetable(T,'m.txt','Delimiter',' ')
I get the variable names Output1 and Output2 as headers in the output text file. I would like to remove both names and instead have a text like DR as the heading.
Mohammad R. Ghassemi
Mohammad R. Ghassemi on 17 Oct 2021
Finally I found that fprintf is a better fuction for my purpose:
fid=fopen('m1.txt', 'w'); % open a file for writing
fprintf(fid,'DR\n'); % print a title
fprintf(fid,'%d %d\n',Output); % print values in column order % two values appear on each row of the file
Thanks all.

Sign in to comment.

Answers (1)

dpb on 17 Oct 2021
As @Ive J points out, define variable names as desired. NB there's no need for intermediate variables here, either--if you already have the variables, then just use them directly:

Community Treasure Hunt

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

Start Hunting!