I need to format a text file
Show older comments
0.6876 1 0CF02A83x Rx d 8 13 7D 00 7D 29 7D C0 FF
0.6882 1 0CFFD183x Rx d 8 1C DE 8F FE FA BD 8A 42
0.6976 1 0CF02A83x Rx d 8 0B 7D 08 7D 2F 7D C0 FF
0.6982 1 0CFFD183x Rx d 8 2B DE CF FB FA E1 8A 42
0.7076 1 0CF02A83x Rx d 8 FD 7C 0D 7D 29 7D C0 FF
0.7082 1 0CFFD183x Rx d 8 3C DE 8F FC FA AD 8A 42
0.7176 1 0CF02A83x Rx d 8 F9 7C 15 7D 25 7D C0 FF
0.7182 1 0CFFD183x Rx d 8 48 DE 2F FE FA 55 8A 42
This is a .txt file with potentially 500000 rows, only 8 are displayed for my question
I want to write a Matlab script to perform these 5 steps on the .txt file above:
1) remove every row that contains F02A
2) remove these items from the remaining rows 1 0CFFD183x Rx d 8 leaving only the 8 HEX values
3) keep only the first two bytes of the HEX values as in rows 2, 4, 6, 8, want to have only 1C DE remaining
example:
1C DE
2B DE
3C DE
48 DE
5) last step is to convert to Decimal, then perform this math
example for row one (DE*256)+1C)/DE or ((222*256)+28)/222 =
example for row two (DE*256)+2B)/DE or ((222*256)+43)/222 =
which produces this for first and second rows above etc
256.1261
256.1936
.
.
.
Thanks for answering
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Check in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!