Importing CSV files into MATLAB
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hans123
el 22 de Mayo de 2019
Respondida: Walter Roberson
el 22 de Mayo de 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 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!