how to import csv file in matlab

N
Nur Zakaria · Dec 29, 2023 · 2.1K views
Question
Hi, I have one question. I need to import data into MATLAB from a CSV file. Unfortunately, the data has header information in 3 columns.   How do I skip the headers and get the data directly?   For example:   a= import data ('C:\s11.dat') * Then what is the next step? I need your help.
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Aug 12, 2026

To import data from a CSV file into MATLAB use the “readtable” function. The “readtable” function automatically detects the header and the number of lines to skip. 

 

T = readtable('myfile.csv');

Alternatively, you can specify the number of lines to skip using:

T = readtable('myfile.csv','NumHeaderLines',3);  % skips the first three rows of data

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!