How to write Output text file in Tabular format in matlab??
Show older comments
X contains 61 decimal integers like 0.0123 0.9876 and so on. Y contains 61 decimal integers like 0.0123 0.9876 and so on. Z contains 61 decimal integers like 0.0123 0.9876 and so on. I want an output text file containing 3 columns-X,Y and Z. Please help.
1 Comment
ANKUR KUMAR
on 1 Oct 2018
@Virajan Verma Accept the answer if it helps you.
Answers (1)
ANKUR KUMAR
on 1 Oct 2018
I am taking a random data to give you an example.
A=rand(1,61);
B=rand(1,61);
C=rand(1,61);
AA=[A' B' C']
dlmwrite('test.txt',AA)
8 Comments
Virajan Verma
on 1 Oct 2018
ANKUR KUMAR
on 1 Oct 2018
Do you want in matlab table format ?
Just tell us the desired output.
ANKUR KUMAR
on 1 Oct 2018
Do you want in this format?

Walter Roberson
on 1 Oct 2018
What do you mean by "Tabular form" ?
If you need a header line, to do it with dlmwrite() you would have to write the header line first (abusing dlmwrite to do so), and then your dlmwrite() for the data would need to use the append option.
If you want tab delimited columns, then you would tell dlmwrite() to use the tab delimiter.
ANKUR KUMAR
on 1 Oct 2018
If you want in the above format, then use this
A=rand(1,6);
B=rand(1,6);
C=rand(1,6);
AA=[A' B' C']
B=arrayfun(@(x) num2str(x) , AA,'uni',0)
BB=[{'array1','array2','array3'};B]
dlmcell('test.txt',BB)
If still you are not convinced, tell us the format in which you wish the output to be.
Virajan Verma
on 1 Oct 2018
ANKUR KUMAR
on 1 Oct 2018
ANKUR KUMAR
on 2 Oct 2018
Accept the answer if it helps you.
Categories
Find more on Data Import and Export 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!