Importing CSV files into MATLAB
조회 수: 17 (최근 30일)
이전 댓글 표시
I am trying to import multiple CSV data files into MATLAB without manually doing so (by hard coding), I want the data as a double and not in table - so the command
T = readtable('myfile.csv');
or
T = readtable('myfile.csv', 'HeaderLines',3); % skips the first three rows of data
is not the best choice to use. How can I import the data from these comma seperate value files like how dlmread works with Excel files?
Is csvread a good approach? Becuase when I read the litreature (https://www.mathworks.com/help/matlab/ref/csvread.html) it says it is Not Recommended.
I was working with Octave for a while and the dlmread function works well with it, why doesn't MATLAB have that functionality?
댓글 수: 0
채택된 답변
Walter Roberson
2019년 5월 22일
In R2019a there is now readmatrix() for reading numeric values (not mixed data type).
Before that, you can use readtable() and table2array(), provided that you do not have mixed data types.
dlmread() is restricted to numeric values, with the exception that you can tell it how many leading rows and columns to skip, and those skipped rows or columns can contain text. Be careful when you give those parameters, as it is the number to skip, not the offset of the first one you want to read -- so for skipping 3 rows and no columns that would be 3, 0. It is not a starting row -- you would not specify 4, 1 to tell it to start reading from row 4 column 1 for example.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!