Matlab reads csv file csvread()

Matlab reads csv file csvread()

There are three ways to use csvread()

  1. way 1

    M = csvread('filename');
    

    Enter the file name directly, read the data into the matrix M, and require the csv file to contain only numbers

  2. way 2

    M = csvread('filename',row,col);
    

    In addition to the file name, the line number (row) and column number (col) of the start reading position are also specified, and the line number and column number start counting from 0.

    row=0, col=0, means to start reading from the first number in the file

  3. way 3

    M = csvread('filename',row,col,range);
    

    range defines the reading range, range = [R1 C1 R2 C2], (R1, C1)is the upper left corner of the reading area, and (R2,C2)is the lower right corner of the reading area. It is required that row and col are equal to the first two items in range.

The empty items in the csv file will be initialized to 0 when read into the matrix.

Guess you like

Origin blog.csdn.net/first_bug/article/details/130949384