matlab/matlab-agentic-toolkit / skills-catalog/test-and-measurement/matlab-import-export-vehicle-data
matlab-import-export-vehicle-data
VerifiedUse when importing or exporting vehicle data from/to log files (MDF/MF4/DAT, BLF, ASC/TXT), decoding CAN/CAN FD/LIN messages to signals via DBC, ARXML, or LDF databases, writing timetable data to MDF or BLF files, or calling blfread, blfinfo, blfwrite, mdfRead, mdfWrite, mdfCreate, mdfInfo, canSignalImport, canMessageImport, canMessageTimetable, canFDMessageTimetable, canSignalTimetable, or linMessageTimetable.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.4 KB |
| manifest.yaml | config | 661 B |
| references/asc-import.md | markdown | 3.4 KB |
| references/blf-import.md | markdown | 3.6 KB |
| references/blf-writing.md | markdown | 7.5 KB |
| references/can-decode.md | markdown | 2.0 KB |
| references/canfd-decode.md | markdown | 1.9 KB |
| references/database-objects.md | markdown | 2.4 KB |
| references/dbc-multiplexing-syntax.md | markdown | 4.9 KB |
| references/lin-decode.md | markdown | 2.0 KB |
| references/mdf-import.md | markdown | 4.4 KB |
| references/mdf-writing.md | markdown | 7.3 KB |
| references/simple-demultiplexing.md | markdown | 4.8 KB |
references/mdf-import.md
View on GitHub# MDF/MF4/DAT File Import
For function syntax, run `help mdfInfo`, `help mdfRead`, `help mdfChannelGroupInfo`, or `help mdfChannelInfo` in MATLAB.
**Do not use the deprecated `mdf()` object constructor.** Always use the functional API: `mdfRead`, `mdfInfo`, `mdfChannelGroupInfo`, `mdfChannelInfo` (available R2023a+). The `mdf()` class and its methods (`.read()`, `.get()`, `.ChannelGroup`) are legacy and should not be used in new code.
MDF files (`.mf4`, `.mdf`, `.dat`) contain multiple "channel groups" that can hold different types of data.
## File-Level Metadata with mdfInfo
```matlab
fileInfo = mdfInfo(mdfFile);
```
Returns an `MDFInfo` object with properties: `Version` (MDF format version), `ProgramIdentifier`, `InitialTimestamp`, `ChannelGroupCount`, `Author`, `Department`, `Project`, `Subject`, `Comment`. Use this for a quick overview before inspecting individual groups.
## Inspecting Channel Groups
```matlab
groupInfo = mdfChannelGroupInfo(mdfFile);
```
Returns a table with columns including `NumSamples`, `AcquisitionName` (categorical, may be `<undefined>`).
## Inspecting Channels Within a Group
```matlab
channelInfo = mdfChannelInfo(mdfFile, GroupNumber=g);
channelInfo = mdfChannelInfo(mdfFile); % all groups
channelInfo = mdfChannelInfo(mdfFile, Channel="LIN_Frame.*"); % wildcard
```
## Reading Data with mdfRead
```matlab
data = mdfRead(mdfFile, GroupNumber=g);
tt = data{1}; % timetable for that group
```
`mdfRead` always returns a cell array. Extract with `data{1}`.
Reading multiple groups returns a cell array where index is sequential (not the group number):
```matlab
data = mdfRead(mdfFile, GroupNumber=[1, 3, 5]);
% data{1} -> group 1, data{2} -> group 3, data{3} -> group 5
```
## Detecting Raw Bus Data vs Decoded Signals
**NEVER use `SourceBusType` or `AcquisitionSourceType` metadata for bus type detection.** These fields are vendor-specific, unreliable, and often absent. Do not include them as a fallback or secondary check. The only reliable method is ASAM channel name prefixes.
**Use ASAM MDF standard channel name prefixes:**
| Prefix | Protocol | Mandatory Channels | Action |
|--------|----------|-------------------|--------|
| `CAN_DataFrame` | CAN / CAN FD | `.ID`, `.DLC`, `.DataLength`, `.DataBytes` | Decode with `canMessageTimetable` or `canFDMessageTimetable` |
| `LIN_Frame` | LIN | `.ID`, `.ReceivedDataByteCount`, `.DataLength`, `.DataBytes` | Decode with `linMessageTimetable` (R2025a+) |
| Neither | Already decoded | N/A | Use timetable directly |
```matlab
varNames = string(tt.Properties.VariableNames);
if any(startsWith(varNames, "CAN_DataFrame"))
% Raw CAN -- see references/can-decode.md or references/canfd-decode.md
elseif any(startsWith(varNames, "LIN_Frame"))
% Raw LIN -- see references/lin-decode.md
else
% Already decoded signals -- use directly
end
```
**Distinguishing CAN vs CAN FD:** Check `DataLength` values. Standard CAN has max 8 bytes; CAN FD can have up to 64 bytes.
**Finding LIN groups:**
```matlab
linChannels = mdfChannelInfo(mdfFile, Channel="LIN_Frame.*");
% GroupNumber column identifies which groups contain LIN data
```
## Decode Pipelines
For decode pipelines, see the protocol references:
- [CAN decode](can-decode.md) -- `canMessageTimetable` + `canSignalTimetable`
- [CAN FD decode](canfd-decode.md) -- `canFDMessageTimetable` + `canSignalTimetable`
- [LIN decode](lin-decode.md) -- `linMessageTimetable`, signal access
## Complete MDF Pipeline
```matlab
db = canDatabase(dbcFile);
data = mdfRead(mdfFile);
signals = struct();
for i = 1:numel(data)
tt = data{i};
if height(tt) == 0
continue
end
varNames = string(tt.Properties.VariableNames);
if any(startsWith(varNames, "CAN_DataFrame"))
try
msgTT = canMessageTimetable(tt, db);
signals.("Group" + i) = canSignalTimetable(msgTT);
catch
signals.("Group" + i) = tt;
end
elseif any(startsWith(varNames, "LIN_Frame"))
signals.("Group" + i) = linMessageTimetable(tt, linDb);
else
signals.("Group" + i) = tt;
end
end
```
## AcquisitionName Handling
`AcquisitionName` is categorical. The value `<undefined>` is NOT a string -- `strlength()` on it throws. Always convert first:
```matlab
acqName = string(groupInfo.AcquisitionName(g));
if ~ismissing(acqName) && strlength(acqName) > 0
groupName = matlab.lang.makeValidName(acqName);
end
```
----
Copyright 2026 The MathWorks, Inc.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |