How to add both a comma AND a carriage return to a file during export

1 visualizzazione (ultimi 30 giorni)
I would like to export a file of a vector like: xlswrite(filename,M) or csvwrite(filename,M)
Where M is a vector.
I would like the text file to look like:
1000,
2000,
3000,
...
etc.
Basically I would like to make the file with both a comma then a carriage return. I tried dlmwrite but you can only do one delimiter.
Any help would be appreciated.

Risposta accettata

Stephen23
Stephen23 il 26 Mag 2017
Modificato: Stephen23 il 26 Mag 2017
You could use fprintf:
fid = fopen(fnm,'wt');
fprintf(fid,'%d,\n',M);
fclose(fid);
Remember to specify the format string to suit the desired number format.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by