csvwrite
Writes a numeric matrix to a comma-separated file.
Category: Data Import and Analysis > Data Import and Export
Syntax
csvwrite(filename, M)
Writes M, one matrix row per line.
Description
This is dlmwrite with a comma as the delimiter. Values are written with up to five significant digits, so it is not suited to data that needs full precision. For that, use dlmwrite with the 'precision' option or writematrix.
Input arguments
filename- Name of the output file. An existing file is overwritten.
M- Numeric matrix.
Example
Write and show the file
csvwrite('m.csv', [1 2 3; 4 5 6]);
disp(fileread('m.csv'))
csvread('m.csv')
Output
1,2,3
4,5,6
ans = 2×3
1 2 3
4 5 6