Matlab Import Export Vehicle Data
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Software development
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to handling vehicle network data within MATLAB. It covers the import and export of various log file formats including MDF/MF4, BLF, ASC, and TXT. It facilitates the decoding of raw CAN, CAN FD, and LIN frames into signals using database files such as DBC, ARXML, and LDF. Additionally, it supports writing timetable data to MDF or BLF files, ensuring proper handling of metadata and data types for vehicle communication analysis.
What it does
- Reads vehicle bus log files in formats like MDF, BLF, ASC, and TXT.
- Decodes raw CAN, CAN FD, and LIN frames into signals using database files.
- Writes MATLAB timetable data to MDF/MF4 and BLF files.
- Handles polymorphic return types from vehicle network read functions.
- Provides pipelines for converting raw message timetables into signal data.
- Supports inspection of BLF file structures and channel configurations.
When to use it
- When you need to import vehicle network logs into MATLAB for analysis.
- When you must decode raw bus frames into readable signals using DBC, ARXML, or LDF files.
- When you need to export processed timetable data back into standard vehicle log formats.
- When working with multi-channel log files that require specific extraction patterns.
Advantages
- Integrates directly with MATLAB Vehicle Network Toolbox functionality.
- Provides standardized workflows for common vehicle network protocols.
- Supports both raw message access and high-level signal decoding.
- Includes guidance on handling complex data types and file metadata.
Usage examples
- “How do I import a CAN log file and decode it into signals?”
- The agent will guide you to load your DBC file using canDatabase, read the log file using the appropriate function (e.g., blfread or canSignalImport), and apply the decoding pipeline to generate a signal timetable.
- “Can I write my MATLAB timetable to an MDF file?”
- The agent will explain the use of mdfWrite, including the necessary steps to set the RowTimes timezone and convert unsupported data types like logical or categorical columns.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/matlab/matlab-import-export-vehicle-data/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-import-export-vehicle-data.zip -d .agents/skills
Documentation by MathWorks
Import, Export, and Decode Vehicle Data
Import, decode, and export vehicle network log files in MATLAB using Vehicle Network Toolbox (VNT).
When to Use
Reading
.mf4/.mdf/.dat,.blf,.asc, or.txtvehicle bus log filesDecoding raw CAN/CAN FD frames to signals via DBC or ARXML databases
Demultiplex signals from raw CAN/CAN FD frames via DBC databases in the case of simple multiplexing (R2026a or earlier)
Decoding LIN frames via LDF databases (R2025a+)
Handling polymorphic return types from VNT read functions
Writing MATLAB timetable data to MDF/MF4 files with
mdfWriteWriting CAN/CAN FD message data to BLF files with
blfwriteConverting unsupported timetable types (logical, categorical, cell, datetime columns) for MDF export
When Not To Use
Simulink CAN configuration
Live CAN channel access
XCP/A2L workflows
Demultiplexing of signals in the case of hierarchical or extended multiplexing
Demultiplexing of signals via ARXML or LIN databases
Writing LIN data to BLF (unsupported by VNT's
blfwrite-- use MDF instead)Writing to ASC or TXT files (no
canMessageExportexists -- use BLF or MDF instead)
Prerequisites
Before running any operations, determine the MATLAB version:
r = matlabRelease;
tok = regexp(r.Release, 'R(\d{4})([ab])', 'tokens');
matlabYear = str2double(tok{1}{1});
matlabLetter = tok{1}{2};Before calling BLF/ASC/TXT import or CAN/CAN FD/LIN decode functions, call detect_matlab_toolboxes to confirm Vehicle Network Toolbox is installed. If unavailable, tell the user. Once confirmed in a session, do not re-check.
MDF functions (mdfRead, mdfChannelGroupInfo, mdfInfo, mdfChannelInfo) are base MATLAB (R2023a+) and do not require VNT. Do not use the deprecated mdf() object constructor -- always use the functional API. For reading all groups blindly, mdfRead alone is acceptable. To selectively read or inspect structure first, use mdfChannelGroupInfo or mdfInfo.
For R2026a and earlier, multiplexing is not natively supported in Vehicle Network Toolbox. Apply the demultiplexing modifications described below to decoded signals.
Decode Pipeline
| Source Format | CAN | CAN FD | LIN | Raw (no decode) |
|---|---|---|---|---|
| ASC | canSignalImport(f,"Vector",db) | same | -- | canMessageImport(f,"Vector",OutputFormat="timetable") |
| TXT | canSignalImport(f,"Kvaser",db) | same | -- | canMessageImport(f,"Kvaser",OutputFormat="timetable") |
| BLF | blfread(f,Database=db) -> canSignalTimetable | blfread(f,Database=db) -> canFDMessageTimetable -> canSignalTimetable | blfread(f,Database=linDb,ProtocolMode="LIN") -> linMessageTimetable | blfread(f) |
| MDF/MF4/DAT | mdfRead -> canMessageTimetable(tt,db) -> canSignalTimetable | mdfRead -> canFDMessageTimetable(tt,db) -> canSignalTimetable | mdfRead -> linMessageTimetable(tt,linDb) | mdfRead -> timetable directly |
Database Loading
db = canDatabase("path/to/file.dbc"); % CAN and CAN FD
db = arxmlDatabase("path/to/file.arxml"); % CAN only (not CAN FD)
linDb = linDatabase("path/to/file.ldf"); % LIN (R2025a+)Load once, pass to all decode calls. Multiple databases: canMessageTimetable(tt, [db1, db2]).
Database inspection for DBC files and classification of the multiplexing scheme
In case of DBC files only, determine whether the file contains definitions of multiplexed signals that use extended or hierarchical multiplexing.
For MATLAB R2026a or earlier, it is not possible to determine the multiplexing scheme from the canDatabase object directly. Therefore, inspect the raw DBC text to classify the multiplexing scheme, by
reading the DBC file as text using fileread():
dbcText = fileread("path/to/file.dbc");Check for extended multiplexing indicators. See references/dbc-multiplexing-syntax.md for the full syntax guide — consult it when parsing unfamiliar DBC signal markers or SG_MUL_VAL_ entries.
hasSgMulValEntries = ~isempty(regexp(dbcText, '^SG_MUL_VAL_\s+\d+', 'once', 'lineanchors'));
hasNestedMuxor = ~isempty(regexp(dbcText, 'SG_\s+\w+\s+m\d+M\s', 'once'));
hasExtendedMux = hasSgMulValEntries || hasNestedMuxor;Note: SG_MUL_VAL_ may appear in the NS_ (namespace) section as a keyword declaration — this does NOT indicate extended multiplexing. Only match actual data entries that start at the beginning of a line followed by a numeric message ID.
If hasExtendedMux is true, identify which specific messages are affected by parsing the message IDs from SG_MUL_VAL_ entries:
sgMulValMsgIds = regexp(dbcText, '^SG_MUL_VAL_\s+(\d+)', 'tokens', 'lineanchors');
extendedMuxMsgIds = unique(cellfun(@(x) str2double(x{1}), sgMulValMsgIds));For R2026a and earlier, filter out messages with extended multiplexing (identified in extendedMuxMsgIds) and inform the user.
Key Constraints
Polymorphic returns: All VNT read functions (
canSignalImport,blfread,mdfRead,canMessageImport) return different types based on channel count and parameters. Always guard withiscell()/istimetable()/isstruct(). When checking multi-channel results, useiscell()as the primary guard to branch between cell array (multi-channel) vs direct timetable (single channel), then iterate or extract with{n}or{i}.ARXML + CAN FD:
arxmlDatabasedoes not support CAN FD in MATLAB. It cannot be used withcanFDMessageTimetable. When the user provides an ARXML file for CAN FD data, always explain that ARXML does not support CAN FD and they must usecanDatabasewith a DBC file instead. Do not silently switch to DBC without explaining why.ARXML for CAN (non-FD): When the user provides an ARXML file for standard CAN decode, use
arxmlDatabaseexclusively. Do not also loadcanDatabaseas a fallback -- the ARXML database object works identically incanMessageTimetableandcanSignalTimetable. Only usecanDatabasewhen the user provides a DBC file.No
canFDSignalTimetable: This function does not exist. UsecanSignalTimetablefor both CAN and CAN FD signals.BLF LIN requires
ProtocolMode="LIN": Without it,blfreadreturns only CAN data.No signal-level LIN decode: Only
linMessageTimetableexists. Access signal values from timetable columns directly.MDF raw CAN detection: Use channel name prefixes
CAN_DataFrame/LIN_Frame(ASAM standard). NEVER useSourceBusTypeorAcquisitionSourceTypemetadata -- not even as a fallback. These fields are vendor-specific and unreliable.canMessageImportdefault format: Returns legacycan.Messagearray. Always passOutputFormat="timetable".Cell extraction: Multi-channel calls to
blfread,mdfRead, andcanMessageImportreturn cell arrays. Extract with{n}before processing.Use
canSignalImportfor ASC/TXT signals: It decodes in one call. Only usecanMessageImportwhen raw message timetables are needed.
File-Specific References
ASC import --
canSignalImport/canMessageImportwith Vector and Kvaser vendors, polymorphic return type handling for multi-channel filesBLF import --
blfinfofor file inspection,blfreadwith and without ChannelID, CAN vs LIN protocol selectionMDF import --
mdfRead/mdfChannelGroupInfo/mdfChannelInfo, detecting raw CAN/LIN groups by channel name, reading specific groups
Protocol References
CAN decode --
canMessageTimetableandcanSignalTimetablepipelines, DBC and ARXML database usageCAN FD decode --
canFDMessageTimetablepipeline, why ARXML does not work for CAN FDLIN decode --
linMessageTimetableusage, accessing signal values from timetable columns (no signal-level function exists)Database objects --
canDatabasevsarxmlDatabasevslinDatabase, which decode functions accept which database type
Demultiplexing References
Simple demultiplexing --
canDatabase,canMessageTimetable,canFDMessageTimetable,canSignalTimetablepipelines and signal demultiplexing
Export Workflows
MDF Writing
Writing MATLAB timetable data to MDF/MF4 files with mdfWrite.
| Task | Function | Notes |
|---|---|---|
| Write timetable to new file | mdfWrite(file, tt) | Appends channel group; file created with warning if missing |
| Overwrite existing group | mdfWrite(file, tt, GroupNumber=N) | Must read with IncludeMetadata=true first |
| Set file metadata | mdfCreate(file, FileInfo=minfo) then mdfWrite() | Supported: Author, Department, Project, Subject, Comment |
| Convert unsupported types | See references/mdf-writing.md | logical -> uint8(), categorical -> double() (stores category index), cell -> string(), datetime col -> posixtime() |
| Write raw CAN frames | Use CAN_DataFrame.ID/DLC/DataLength/DataBytes column naming (ASAM standard) | All 4 columns mandatory (ID, DLC, DataLength, DataBytes). Omitting any one breaks canMessageTimetable re-import. |
| Write raw LIN frames | Use LIN_Frame.ID/ReceivedDataByteCount/DataLength/DataBytes column naming | ASAM standard LIN frame naming |
| Handle datetime RowTimes | Required step: Set .TimeZone = 'UTC' before writing: tt.Properties.RowTimes.TimeZone = 'UTC'; | Alternatively convert to duration -- both work. Omitting this causes mdfWrite to error or produce unreadable timestamps. |
BLF Writing
Writing CAN and CAN FD message data to BLF files with blfwrite.
| Task | Function | Notes |
|---|---|---|
| Write CAN messages | blfwrite(file, tt, chanID, 'CAN') | Use canMessageTimetable to format tt; do not manually build columns |
| Write CAN FD messages | blfwrite(file, tt, chanID, 'CAN FD') | Use canFDMessageTimetable to format tt; up to 64-byte payloads. See references/blf-writing.md for the 13 required columns when building from scratch. |
| CAN/CAN FD mixed | Both supported in one BLF file | Use explicit protocol string per call |
LIN is not supported by VNT's blfwrite. Use MDF for LIN logging. When the user asks to write LIN data to BLF, state this limitation immediately -- do not attempt workarounds or partial solutions before explaining the constraint.
ASC/TXT writing is not supported. There is no canMessageExport counterpart to canMessageImport. Use BLF or MDF for export.
Export References
MDF writing --
mdfWrite/mdfCreate, type conversion, ASAM CAN/LIN naming, overwriting groups, metadata preservationBLF writing --
blfwritewith CAN/CAN FD,canMessageTimetable/canFDMessageTimetableformatting, channel callbacks
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.1 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md11.4 KiB
- manifest.yaml661 B
- references/asc-import.md3.4 KiB
- references/blf-import.md3.6 KiB
- references/blf-writing.md7.5 KiB
- references/can-decode.md2.0 KiB
- references/canfd-decode.md1.9 KiB
- references/database-objects.md2.4 KiB
- references/dbc-multiplexing-syntax.md4.9 KiB
- references/lin-decode.md2.0 KiB
- references/mdf-import.md4.4 KiB
- references/mdf-writing.md7.3 KiB
- references/simple-demultiplexing.md4.8 KiB
references/dbc-multiplexing-syntax.md
DBC File Multiplexing Syntax
How to identify multiplexing type by reading a DBC file as text.
Signal Definition Markers
In a SG_ line, the multiplexing marker appears after the signal name:
| Marker | Meaning | Example |
|---|---|---|
M | Multiplexor signal (the selector) | SG_ OBD2Mode M : 16|7@1+ ... |
m<N> | Multiplexed signal (active when muxor == N) | SG_ Vehicle_Speed m13 : 6|8@1+ ... |
m<N>M | Signal is both multiplexed AND a multiplexor (nested) | SG_ S1 m0M : 8|8@1+ ... |
| (none) | Regular signal, always present | SG_ Temperature_regular : 24|8@1+ ... |
Detecting Extended/Hierarchical Multiplexing
A message uses extended multiplexing if ANY of these conditions are true:
SG_MUL_VAL_section exists at the end of the file with entries referencing signals in that message:SG_MUL_VAL_ 16 S6 S0 2-2; SG_MUL_VAL_ 16 S1 S0 0-0, 1-1;The format is:
SG_MUL_VAL_ <msgID> <muxedSignal> <muxorSignal> <range1>[, <range2>...];Value ranges (N-M) instead of scalar values indicate extended multiplexing.A signal has the
m<N>Mmarker — it is both multiplexed by a parent AND acts as a multiplexor for children (nested hierarchy).Multiple
M-marked signals exist in the same message (multiple independent multiplexors at the same level).
Detecting Simple Multiplexing
A message uses simple multiplexing if:
Exactly one signal has the
Mmarker (the multiplexor)One or more signals have
m<N>markers (the multiplexed signals)NO signal has the
m<N>Mcombined markerNO
SG_MUL_VAL_entries reference that message's signals
Example: Simple Multiplexing (OBD2_Message)
BO_ 55 OBD2_Message: 5 Vector__XXX
SG_ Temperature_regular : 24|8@1- (1,0) [0|0] "" Vector__XXX
SG_ Vehicle_Speed m13 : 6|8@1+ (1,0) [0|255] "km/h" Vector__XXX
SG_ Accelerator m73 : 2|8@1+ (0.392156862745098,0) [0|100] "" Vector__XXX
SG_ OBD2Mode M : 16|7@1+ (1,0) [0|127] "" Vector__XXX
SG_ Engine_Torque m98 : 0|8@1+ (1,-125) [-125|130] "rpm" Vector__XXXOBD2Modeis the sole multiplexor (M)Vehicle_Speed,Accelerator,Engine_Torqueare multiplexed (m13,m73,m98)Temperature_regularis a regular signal (no marker)
Example: Extended/Hierarchical Multiplexing
BO_ 1718 PowerTrainTires: 4 Vector__XXX
SG_ FailureFlagRear m2 : 18|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ FailureFlagFront m0 : 18|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ PressureRR m1 : 24|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ PressureRL m1 : 24|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ PressureFR m1 : 24|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ PressureFL m1 : 24|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ TemperatureRR m1 : 19|5@1+ (1,0) [0|0] "" Vector__XXX
SG_ TemperatureRL m1 : 19|5@1+ (1,0) [0|0] "" Vector__XXX
SG_ TemperatureFR m1 : 19|5@1+ (1,0) [0|0] "" Vector__XXX
SG_ TemperatureFL m1 : 19|5@1+ (1,0) [0|0] "" Vector__XXX
SG_ WheelSpeedRR m0 : 19|13@1- (1,0) [0|0] "" Vector__XXX
SG_ WheelSpeedRL m0 : 19|13@1- (1,0) [0|0] "" Vector__XXX
SG_ WheelSpeedFR m0 : 19|13@1- (1,0) [0|0] "" Vector__XXX
SG_ WheelSpeedFL m0 : 19|13@1- (1,0) [0|0] "" Vector__XXX
SG_ DataRR m3M : 16|2@1+ (1,0) [0|0] "" Vector__XXX
SG_ DataRL m2M : 16|2@1+ (1,0) [0|0] "" Vector__XXX
SG_ DataFR m1M : 16|2@1+ (1,0) [0|0] "" Vector__XXX
SG_ DataFL m0M : 16|2@1+ (1,0) [0|0] "" Vector__XXX
SG_ VehicleSpeed m13 : 8|8@1- (1,0) [0|0] "" Vector__XXX
SG_ EngineTorque m48 : 8|8@1- (1,0) [0|0] "" Vector__XXX
SG_ AcceleratorPedal m23 : 8|8@1+ (1,0) [0|0] "" Vector__XXX
SG_ TireMux M : 6|2@1+ (1,0) [0|0] "" Vector__XXX
SG_ PowerTrainMux M : 0|6@1+ (1,0) [0|0] "" Vector__XXX
SG_MUL_VAL_ 1718 FailureFlagRear TireMux 2-2, 3-3;
SG_MUL_VAL_ 1718 FailureFlagFront TireMux 0-0, 1-1;
SG_MUL_VAL_ 1718 PressureRR DataRR 1-1;
SG_MUL_VAL_ 1718 PressureRL DataRL 1-1;
SG_MUL_VAL_ 1718 PressureFR DataFR 1-1;
SG_MUL_VAL_ 1718 PressureFL DataFL 1-1;
SG_MUL_VAL_ 1718 TemperatureRR DataRR 1-1;
SG_MUL_VAL_ 1718 TemperatureRL DataRL 1-1;
SG_MUL_VAL_ 1718 TemperatureFR DataFR 1-1;
SG_MUL_VAL_ 1718 TemperatureFL DataFL 1-1;
SG_MUL_VAL_ 1718 WheelSpeedRR DataRR 0-0;
SG_MUL_VAL_ 1718 WheelSpeedRL DataRL 0-0;
SG_MUL_VAL_ 1718 WheelSpeedFR DataFR 0-0;
SG_MUL_VAL_ 1718 WheelSpeedFL DataFL 0-0;
SG_MUL_VAL_ 1718 DataRR TireMux 3-3;
SG_MUL_VAL_ 1718 DataRL TireMux 2-2;
SG_MUL_VAL_ 1718 DataFR TireMux 1-1;
SG_MUL_VAL_ 1718 DataFL TireMux 0-0;
SG_MUL_VAL_ 1718 VehicleSpeed PowerTrainMux 13-13;
SG_MUL_VAL_ 1718 EngineTorque PowerTrainMux 48-48;
SG_MUL_VAL_ 1718 AcceleratorPedal PowerTrainMux 23-23;Extended indicators:
TireMuxandPowerTrainMux— both are multiplexors (M) at the same hierarchical levelSG_MUL_VAL_section defines hierarchical parent-child relationshipsTireMux 2-2, 3-3;andTireMux 0-0, 1-1;define non-scalar ranges of multiplexor valuesm0M,m1M,m2M,m3Mindicate thatDataFL,DataFR,DataRL,DataRRare both multiplexors and multiplexed
Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/test-and-measurement/matlab-import-export-vehicle-data · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-import-export-vehicle-data.zip