Column names in data sheet

3 ビュー (過去 30 日間)
Huugin
Huugin 2013 年 6 月 11 日
Hi
I have created this data sheet I would like load into matlab. If I leave the data sheet as merely numbers it imports fine using the "load" command. But what if I want to organize the data sheet a bit, and insert column names? I have tried enclosing the column headers/names in quotes, but "load" just complains about unrecognized text. The command "importdata" however terminates without complaint but produces the following output
>> test=importdata('data.txt')
test =
data: [25x4 double]
textdata: {'a ' 'b ' 'c' 'd'}
colheaders: {'a ' 'b ' 'c' 'd'}if true
Here my data set contains 25 x 4 numeric values, and at the top I have written the column names: a b c d. But how do I then get to the data? I have tried
test(a) 'complains that it does not recognize a
test('a') 'complains that the Index exceeds matrix dimensions
test(:,'a') 'complains that the Index exceeds matrix dimensions
test('a',:) 'complains that the Index exceeds matrix dimensions
All help is greatly appreciated, thanks :-)
have a good day

採用された回答

Vishal Rane
Vishal Rane 2013 年 6 月 13 日
編集済み: Vishal Rane 2013 年 6 月 13 日
In your case test is a structure with three fields data, textdata and colheaders. Then again whether it is a matrix, struct or a cell array depends on the source of data.
To access data , use
test.data % all data
test.data(:,1) % first column
test.data(1,:) % first row

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by