Read conversion rule from a mdfObj

5 次查看(过去 30 天)
My Matlab script reads mf4 files from a large measurement campaign. Each signal has a coversion rule (as explained here: Conversion rules) and in addition numerical quantities can be replaced by textual descriptions.
With the setting Conversion="all" you also get this textual description, but I need this description separately to be able to overwrite the numerical y-value with the respective textual description.
My workaround is to load the data with the option Conversion="all" and without this option. Then I can derive the mapping myself.
Is there a better way to do this?
My hope was that this parameter (text description) can be found in one of the properties, e.g. here in signal.Properties.CustomProperties
Unfortunately, I have not found anything yet. Therefore I am grateful for any hints.
mdfObj = mdf(filename);
Data = read(mdfObj, GroupNo, Channel, IncludeMetadata=true);
Data_all = read(mdfObj, GroupNo, Channel, IncludeMetadata=true, Conversion="all");

回答(1 个)

Harsha Vardhan
Harsha Vardhan 2023-9-6
Hi,
I understand that you are trying to read both the raw data as well as the converted data (called as physical data) using a single read of the file. And then you want to map the corresponding raw and physical data of a signal.
Either Properties or Properties.CustomProperties does not have the conversions stored
I tried the following approach to check if such converted data is available in the Properties or Properties.CustomProperties of the returned table.
openExample('vnt/ReadingDataWithConversionFromAnMDFFileExample')
mdfObj = mdf("MDF_Conversion_Example.mf4");
data = read(mdfObj,1,"Gear position",IncludeMetadata=true) %Reading "Gear Position" channel data without conversion
Output of the table
data =
5×1 timetable
Time GearPosition
________ ____________
0 sec 2
0.25 sec 3
0.5 sec 0
0.75 sec 2
1 sec 1
Now, reading with conversion enabled as seen below
data_all = read(mdfObj, 1, "Gear position", IncludeMetadata=true, Conversion="All") %Reading with Conversion enabled
data_all =
5×1 timetable
Time GearPosition
________ ___________________
0 sec {'Gear position 2'}
0.25 sec {'Gear position 3'}
0.5 sec {'Invalid' }
0.75 sec {'Gear position 2'}
1 sec {'Gear position 1'}
Next, the I anlayzed the Properties and Properties.CustomProperties of the table.
data_all.Properties.CustomProperties
ans =
CustomProperties with properties:
ChannelGroupAcquisitionName: "Signal with conversions"
ChannelGroupComment: ""
ChannelGroupSourceInfo: [1×1 struct]
ChannelDisplayName: ""
ChannelComment: ""
ChannelUnit: ""
ChannelType: FixedLength
ChannelDataType: IntegerUnsignedLittleEndian
ChannelNumBits: 8
ChannelComponentType: None
ChannelCompositionType: None
ChannelSourceInfo: [1×1 struct]
ChannelReadOption: All
data_all.Properties
ans =
TimetableProperties with properties:
Description: 'Signal with conversions'
UserData: []
DimensionNames: {'Time' 'Variables'}
VariableNames: {'GearPosition'}
VariableDescriptions: {'Gear position'}
VariableUnits: {''}
VariableContinuity: []
RowTimes: [5×1 duration]
StartTime: 0 sec
SampleRate: 4
TimeStep: 0.25 sec
Events: []
Custom Properties (access using t.Properties.CustomProperties.<name>):
ChannelGroupAcquisitionName: "Signal with conversions"
ChannelGroupComment: ""
ChannelGroupSourceInfo: [1×1 struct]
ChannelDisplayName: ""
ChannelComment: ""
ChannelUnit: ""
ChannelType: FixedLength
ChannelDataType: IntegerUnsignedLittleEndian
ChannelNumBits: 8
ChannelComponentType: None
ChannelCompositionType: None
ChannelSourceInfo: [1×1 struct]
ChannelReadOption: All
For more information about different ways of reading MDF files, please refer to the MDF file documentation - https://www.mathworks.com/help/vnt/referencelist.html?type=function&category=mdf-files
  1 个评论
Michael Muerken
Michael Muerken 2023-9-6
You are absolutely right.
I have built a small workaround and load once the raw data and once the physical data (e.g. instead of a 0 is now in the data 'Gear Neutral'). Then I use the unique to find the positions in the physical vector. The disadvantage is that only the occurring physical quantities are captured and not all.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vehicle Calibration 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by