Home > Common Problem > body text

How matlab reads csv files

coldplay.xixi
Release: 2023-01-13 00:32:16
Original
64488 people have browsed it

How to read csv files in matlab: first open the "matlab" software on the computer and find the csv file on the computer; then enter the code in the command line window at the arrow, the command is [csvread()]; finally In brackets is [the directory file name of the csv file].

How matlab reads csv files

The operating environment of this article: Windows 7 system, matlab r2016b version, Dell G3 computer.

How matlab reads csv files:

1. First open the "matlab" software on the computer. The main interface is as shown below, with the command line window at the arrow. Enter the code to run.

How matlab reads csv files

#2. Next, find the csv file on the computer, as shown in the figure below. The name of the csv file is data.csv.

How matlab reads csv files

3. The command for matlab to read csv files is csvread(), and the directory file name of the csv file is in brackets. The storage directory of data.csv is C:\Users\50123\Desktop\data.csv. The directory of each file is different, just check the properties of the file.

How matlab reads csv files

4. If you need to output specific rows and columns of the csv file, use a=csvread(filename,1,2) to output the second to fourth lines of the file. From the third column to the fourth column, the output result is as shown in the figure below. When matlab reads the csv file, 0 is used as the first row and first column.

How matlab reads csv files

5. Use the command a=csvread(filename,1,0,[1,0,2,3]) to output the second to third lines of the file , the first to fourth columns, the output results are shown in the figure below.

How matlab reads csv files

#6. If the file is all data, you can drag the file to the matlab workspace. The system pop-up window will appear as shown below. You can see the file at the arrow. The data.

How matlab reads csv files

#7. Select the data to be exported and select the type of imported data in "Imported Data". You can export it as a column vector or numerical matrix. Click the arrow "Import selected content" to export the data.

How matlab reads csv files

#8. Next, you can see the exported data in the matlab workspace, as shown in the figure below.

How matlab reads csv files

If you want to learn more about programming, please pay attention to php trainingcolumn!

The above is the detailed content of How matlab reads csv files. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template