How do I manipulate a large row and column datafile and convert each of many bytes to decimal from HEX

1 次查看(过去 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

采纳的回答

Walter Roberson
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 CenterFile Exchange 中查找有关 Numeric Types 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by