How To Export a Matrix as a CSV File in MATLAB? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes 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 export a DataFrame to Excel File in R ? 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 export a DataFrame to Excel File in R ? It is a frequent requirement to save our dataframe for portability after working on it on the auxiliary memory of the computer system using R Programming Language. In this article, we will be using writexl package to export our dataframe to excel(.xlsx). The write_xlsx() function of the writexl pack 3 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 Export List to CSV or text File in R In this article, we will discuss how to export a list to CSV and text file using R Programming language. Exporting to both of these types of files can be done using capture.output() function. This function is mainly used to evaluate its arguments with the output being returned as a character string 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 Like