How do I manipulate a large row and column datafile and convert each of many bytes to decimal from HEX
2 次查看(过去 30 天)
显示 更早的评论
fileID = fopen('new 1.txt', 'r'); %read the .txt file containing data
formatSpec = '%f';
list = fscanf(fileID,formatSpec) % name of data is list
fclose(fileID);
% extract even or Odd lines (use only one)
X1 = list(1:2:end,:); %keep odd rows
X2 = list(2:2:end,:); %keep even rows
Now heres the problem:
the script above works great for a single data row txt file as input...... but how can I perform every other row
extraction on something complicated like this list below with many columns and HEX.... all the FFD1 rows need to
be in one file and all the F02A in another the list will ultimately
grow to 1,000,000 rows length I want to end up with 2 x 500,000 row lists
This data is long, so obviously I wont be doing this by hand and pressing keyboard buttons etc
ultimately I need to separate the rows as stated above, ALSO then convert each byte in HEX to Decimal HELP!! thanks
0.6382 FFD1 24 DE 4F F7 FA 45 8A 42
0.6476 F02A 0F 7D 17 7D 20 7D C0 FF
0.6482 FFD1 13 DE 4F F8 FA 25 8A 42
0.6576 F02A 00 7D 1D 7D 2A 7D C0 FF
0.6582 FFD1 1B DE 6F FC FA 29 8A 42
0.6676 F02A 00 7D 1A 7D 2C 7D C0 FF
0.6682 FFD1 34 DE 8F 00 FB 69 8A 42
0.6776 F02A 0B 7D 09 7D 2B 7D C0 FF
0.6782 FFD1 2C DE 6F 01 FB 7D 8A 42
0.6876 F02A 13 7D 00 7D 29 7D C0 FF
0.6882 FFD1 1C DE 8F FE FA BD 8A 42
0.6976 F02A 0B 7D 08 7D 2F 7D C0 FF
0.6982 FFD1 2B DE CF FB FA E1 8A 42
0.7076 F02A FD 7C 0D 7D 29 7D C0 FF
0.7082 FFD1 3C DE 8F FC FA AD 8A 42
0.7176 F02A F9 7C 15 7D 25 7D C0 FF
0.7182 FFD1 48 DE 2F FE FA 55 8A 42
0 个评论
采纳的回答
Walter Roberson
2022-5-17
Use readlines(), which will return back a string array, one entry per line. Extract the appropriate indices.
arrayfun() a sscanf call with '%*f %*x %x %x %x %x %x %x %x %x" format
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!