Importing CSV files into MATLAB
42 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hans123
am 22 Mai 2019
Beantwortet: Walter Roberson
am 22 Mai 2019
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Mai 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!