TXT export
1 view (last 30 days)
Show older comments
Hello community,
I have a short and simple question. I want to export one vector H and Matrix Ysim to a txt file. This works so far. Furthermore I would like to name the column of the Ysim Matrix in the txt. Any ideas? Thanks
Example:
H=[1;2;3] Ysim=[1,2,3;4,5,6;7,8,9]
dlmwrite('elecdat.txt',[H,Ysim], 'delimiter', '\t', 'precision', 5)
Sarima
0 Comments
Answers (2)
Richard
on 1 May 2012
I would suggest using fprintf instead of dlmwrite:
In order to name the columns in your text files you need to write them as strings and then use fprintf to export them into a text file.
0 Comments
Richard
on 2 May 2012
This code may give you some ideas:
clear all
a = 1;
b = 20;
data = a + (b-a).*rand(100,4);
Heading = {'Data'};
filename = 'E:\University\CEH Lancaster\test.txt';
fid = fopen(filename,'wt');
fprintf(fid,'%s\r\n',Heading{1});
for i = 1:length(data);
fprintf(fid,'%f\t%f\t%f\t%f\r\n',data(i,:));
end
fclose all
2 Comments
See Also
Categories
Find more on Text Files 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!