How to write Output text file in Tabular format in matlab??

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.

Answers (1)

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

Do you want in matlab table format ?
Just tell us the desired output.
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.
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.
Yes. In that format @Ankur Kumar
Accept the answer if it helps you.

Sign in to comment.

Categories

Tags

Asked:

on 1 Oct 2018

Commented:

on 2 Oct 2018

Community Treasure Hunt

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

Start Hunting!