How to import data with column headings?
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hydro
am 24 Dez. 2017
Kommentiert: Hydro
am 24 Dez. 2017
Hello all, attached is a sample of my data. I would like to import the data as a matrix, when I do so, I lose column headings. Importing data as a table will work (see attached), however, I don't want my data to be in table form. I want my data in a matrix with top row as column headings as it is in csv sheet. Any thought would be appreciated. I tried to convert the table into array (table2array) but I lose column heading again.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 24 Dez. 2017
This works for me:
[~, ~, data] = xlsread('data.csv')
What happened when you tried it?
2 Kommentare
Image Analyst
am 24 Dez. 2017
Like Walter says in his answer, that's not possible. You can either do a cell array, like I showed you, or use a table, like you've already done. I suggest you use a table. Tables are great and you'd do yourself a favor to get used to them.
Weitere Antworten (1)
Walter Roberson
am 24 Dez. 2017
In MATLAB, it is not possible to have a header on a numeric matrix. If you want to preserve the headers, you have two options:
- import as a cell array with each entry being in a different cell; or
- import as a table and use the table VariableDescriptions property to store the headers (note: the variable descriptions only show up if you use summary() or ask for them specifically.)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis 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!