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 Center および File ExchangeLow-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