MATLAB Answers

How to read .enf file

23 views (last 30 days)
Denni Goodchild
Denni Goodchild on 28 Oct 2020 at 1:35
Edited: per isakson on 28 Oct 2020 at 3:04
I have an .enf file which I would like to load into matlab and search for a variable. I have converted the enf file to a .txt in order to upload here, assistance reading this file would be greatly appreciated. More specifically, I would like to know what FP1, FP2, FP3 and FP4 equal, the rest of the file is of no importance.
Currently, I have used uiopen which opens the .enf file into a tab in matlab but I am unsure as to how I use it from here.

  0 Comments

Sign in to comment.

Answers (1)

per isakson
per isakson on 28 Oct 2020 at 2:35
Edited: per isakson on 28 Oct 2020 at 3:04
A little exercise with regular expression
>> cssm( 'BFND_W6.txt' )
ans =
struct with fields:
FP1: 'Invalid'
FP2: 'Invalid'
FP3: 'Right'
FP4: 'Left'
where
function sas = cssm( ffs )
%%
xpr = ['^FP1\x20*=\x20*(?<FP1>\S+).*' ...
,'^FP2\x20*=\x20*(?<FP2>\S+).*' ...
,'^FP3\x20*=\x20*(?<FP3>\S+).*' ...
,'^FP4\x20*=\x20*(?<FP4>\S+)' ];
sas = regexp( chr, xpr, 'names', 'lineanchors');
end
Comments:
  1. the "rows" of xpr must appear in the same order as the rows in the data file, i.e. FP1,FP2,FP3,FP4
  2. \x20 is a way to indicate space without using space (it's hex).
  3. Space around = isn't needed for this sample file, but just in case.
  4. The first FPn in a "row" is the name in the text file, the next FPn is the name of the resulting structure field.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!