columns and rows in text file
1 view (last 30 days)
Show older comments
i want to export data from excel file to text file. in excel there are three columns with three rows first two columns contain fractional numbers with two decimal places, third column contains integers
with this piece of code
A = xlsread ('data_file.xlsx', 'Sheet1', 'A1:C10');
fid = fopen ('output.txt', 'w');
dlmwrite (fid, A, '\t' );
fclose (fid)
in the text file i get string 111.11 22.22 50111.12 22.23 50111.13 22.24 50
how should the code looke like to get this in the text file
111.11 22.22 50
111.12 22.23 50
111.13 22.24 50
0 Comments
Accepted Answer
dpb
on 20 Jan 2015
If you need a specific format, dlmwrite and friends aren't (your friends, that is)...
fmt=[repmat('%.2f\t',1,2) '%d\n'];
fprintf(fid,fmt,A.')
2 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!