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");
0 个评论
回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vehicle Calibration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!