- a number with eight digits (positions), %8u
- a number with two positions, %2u
- a string of letters, %24s
Importing non-standard data
1 次查看(过去 30 天)
显示 更早的评论
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???
0 个评论
回答(1 个)
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:
--- 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 个评论
另请参阅
类别
在 Help Center 和 File 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!