Problem writing in data into a csv using fprintf

7 views (last 30 days)
I have a csv file I have written using csvwrite which already contains 3 lines of strings:
fprintf(fid,'abs 3.1 \n');
fprintf(fid,'This is a line \n');
fprintf(fid,'ID Date lat lon val \n');
Now I am trying to fill in data under each column with data in m which is a 10 by 4 marix. Column 1 are ids (5 digits), col.2 are dates (I want is to be in yyyymmddhhmm format but currently is in scientific notation in the table), cols. 3 and 4 are coordinates (e.g. 43.45 & -114.53), and col.5 are some values (e.g. 1.2345).
I have a hard time writing data in the csv. I am currently trying the following piece of code, but data fills in not the way it should be. Data are not stored under each header correctly.
for r=1:size(m,1)
if r~=size(m,1)
Any thoughts is greatly appreciated.

Answers (1)

Muthu Annamalai
Muthu Annamalai on 10 Aug 2015
Edited: Muthu Annamalai on 10 Aug 2015
Have you tried csvwrite or dlmwrite ?
doc csvwrite
doc dlmwrite
Kian on 10 Aug 2015
Edited: Kian on 10 Aug 2015
Thank you, but didn't work.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!