Importing non-standard data

1 次查看(过去 30 天)
Keith
Keith 2012-6-4
Can anyone assist me, I have data that I need to import and then process. A sample (10 llines (contained within a text file) is as follows:
69194111 1EFFFFFFDDDDDDDDDFFEEFFDD
69194111 2DDDDEEEDDDDDDDDDEDEDDDDE
69194111 3DDDDDDDDDDDDDDDDEDDDDDDD
69194111 4DDDDDDDDDDDDDDDDDDDDDDDE
69194111 5EEDDDDEEDDCCDDDDDDDDDDDD
69194111 6DDDDDDDDDDDDDDDDDDDDDDDE
69194111 7DEEEEFEFDDCCCDDDDEDEEEEE
69194111 8EEDDDDDDDDDDDDDDDDDDDDDD
69194111 9DDDDDDDDDDDDDDDDDDDDDDDD
6919411110DDDDDDDDDDDDDDDDDDDDDGDD
First of all, I am unsure how to import the data. Secondly, the numeric part of the data is a date with each letter representing an hour in the day. The format can vary with spaces being at different parts of the numeric part of each line of data.
I need to separate the data part and put each letter in a vector form which can represent (chronologically) the record for consecutive hours over consecutive days. Can any one help???

回答(1 个)

per isakson
per isakson 2012-6-4
Does the file look like this?
69194111 1EFFFFFFDDDDDDDDDFFEEFFDD
69194111 2DDDDEEEDDDDDDDDDEDEDDDDE
69194111 3DDDDDDDDDDDDDDDDEDDDDDDD
69194111 4DDDDDDDDDDDDDDDDDDDDDDDE
69194111 5EEDDDDEEDDCCDDDDDDDDDDDD
69194111 6DDDDDDDDDDDDDDDDDDDDDDDE
69194111 7DEEEEFEFDDCCCDDDDEDEEEEE
69194111 8EEDDDDDDDDDDDDDDDDDDDDDD
69194111 9DDDDDDDDDDDDDDDDDDDDDDDD
6919411110DDDDDDDDDDDDDDDDDDDDDGDD
To me this looks like fixed format:
  1. a number with eight digits (positions), %8u
  2. a number with two positions, %2u
  3. a string of letters, %24s
--- Next step ---
I copy&paste the sample to cssm.txt
fid = fopen( 'cssm.txt', 'r' );
frm = '%8u%2u%24s';
cac = textscan( fid, frm );
fclose( fid );
cac is a cell array. Try
cac{1}, cac{2}, cac{3}
  2 个评论
Keith
Keith 2012-6-4
Hi per isakson - thanks for your prompt response. Yes that is how the the file looks.
I appreciate what you are saying - but what code should I use to import the text file into MATLAB? And then how can I create a vector which facilitates chronologically illustrating the data for consecutive hours over consecutive days.Thanks for any assistance you can provide
per isakson
per isakson 2012-6-5
Now you have three column vectors. Experiment with them.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by