Does 'colheaders' require a minimum array size?

6 次查看(过去 30 天)
I have a peice of code that graphs data, and I use the values stored in 'colheaders' from importing to lable the graphs. In copying the code I discovered that if I have fewer than 1255 data points - the 'colheaders' attribute completely disappears i.e. if I have >1255 data points my file imports a structure with:
data < double >, textdata < cell >
But if I have >1255 data points my file returns a structure with:
data < double >, textdata < cell >, colheaders < cell >
I identified the 1255 min by trial and error i.e. literally just changing the size of the array I was importing, I've also tried adding the '\t' or tab delimiter identifier in my 'importdata' with no luck.
Any ideas on how to create the variable colheaders without having a minimum number of data points? Or more likely, any ideas on what I'm doing wrong as it seems crazy to have a data min restraint here.
Thanks in advance!

回答(1 个)

per isakson
per isakson 2012-6-6
R2012a. I'm lucky with the example from the on-line help. I copy&paste
Day1 Day2 Day3 Day4 Day5 Day6 Day7
95.01 76.21 61.54 40.57 5.79 20.28 1.53
23.11 45.65 79.19 93.55 35.29 19.87 74.68
60.68 1.85 92.18 91.69 81.32 60.38 44.51
48.60 82.14 73.82 41.03 0.99 27.22 93.18
89.13 44.47 17.63 89.36 13.89 19.88 46.60
to the file: ascii_with_colhead.txt
>> A = importdata( 'ascii_with_colhead.txt')
A =
data: [5x7 double]
textdata: {'Day1' 'Day2' 'Day3' 'Day4' 'Day5' 'Day6' 'Day7'}
colheaders: {'Day1' 'Day2' 'Day3' 'Day4' 'Day5' 'Day6' 'Day7'}
What does the field textdata contain with the small file? It is hard for us to understand exactly how you use importdata.
The import data wizard (invoked by the icon in the workspace toolbar) returns the same data, but in three separate variables.
--- More ---
If importdata does not recognize the first column as numbers it will not return colheaders. The text is however included in textdata.
  4 个评论
Natasha
Natasha 2012-6-7
Thank you Walter, didn't realize file exchange was how I was supposed to upload. Thanks!
Walter Roberson
Walter Roberson 2012-6-7
The file exchange is not the way to upload: use one of the commercial servers and post the URL.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by