How To Export a Matrix as a CSV File in MATLAB? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report A CSV file - Comma Separated File, as the name suggests, is a file that stores data delimited by a ' , '. In MATLAB, there is a simple way of exporting a matrix to a csv file. The writematrix() function is used to write a matrix into any desired file type. The syntax is writematrix(<matrix_name>, "filename.extension"); This will create a new file in the current directory with the matrix stored in it. Let us see the same for csv files with various examples. Now, the following is a 2x5 matrix, and we will export it to a csv file named matrix.csv. Example 1: Matlab % MATLAB code for 2x5 matrix, and we will % export it to a csv file named matrix.csv.matrix m = [1 2 3 4 5;10 9 8 7 6]; % Exporting to csv file writematrix(m, 'matrix.csv') Output: The created csv file: Let's export a 4x5 matrix with floating point data to csv file. Example 2: Matlab % MATLAB Code for Exporting a 4x5 matrix % with floating point data to csv file. % Matrix m = [ 1.1 1.2 1.3 1.4 1.5; 2.1 2.2 2.3 2.4 2.5; 3.1 3.2 3.3 3.4 3.5; 4.1 4.2 4.3 4.4 4.5 ]; % Exporting to csv file writematrix(m, 'matrix.csv') Output: The new csv file would be: Comment More infoAdvertise with us Next Article How to Append Data to a File in MATLAB? O owl0223 Follow Improve Article Tags : Software Engineering MATLAB Matrix-Programs Similar Reads How to Append Data to a File in MATLAB? Appending data to a text file means adding data to a file that already exists in the storage. print() function is used to write/append data to a file in MATLAB. It writes formatted text to a file based on the format string provided to it. The format of the output/input is determined by the formattin 4 min read How to Create a Matrix From a Nested Loop in MATLAB? Matrices are 2-dimensional arrays that store numeric or symbolic data. It is convenient to create them with the help of nested loops as the outer loop creates the elements along one dimension and the inner loop creates the elements along the second dimension. In this article, we will see how to crea 2 min read How to Export SQL Server Data to a CSV File? Here we will see, how to export SQL Server Data to CSV file by using the 'Import and Export wizard' of SQL Server Management Studio (SSMS). CSV (Comma-separated values): It is a file that consists of plain text data in which data is separated using comma(,). It is also known as Comma Delimited Files 2 min read How to create a matrix in R In this article, we will discuss What is a matrix and various methods to create a matrix by using R Programming Language. What is a matrix?A matrix is a two-dimensional data set that collects rows and columns. The matrix stores the data in rows and columns format. It is possible to access the data i 3 min read How to Create a New Matrix From All Possible Row Combinations in MATLAB? A  matrix represents a collection of numbers arranged in an order of rows and columns. A matrix encloses the elements in parentheses or brackets.  We will learn how to create a new matrix from all possible row combinations of rows of a different matrix and display the combinations. Procedure of Mak 3 min read How to Convert a CSV File to Microsoft Excel in R CSV refers to Comma-Separated Values. It holds plain text as a series of values (cells) separated by commas (, ) in a series of lines (rows). CSV file can actually open in a text editor and read it. On the other hand, Excel is used to display the data in horizontal and vertical rows. The data are u 2 min read Like