blfread
Read data from Vector BLF file
Description
reads all the data from the specified BLF file and returns a cell array of timetables to the
variable mdata
= blfread(blfFile
)bdata
. The index of each element in the cell array corresponds
to the channel number of the data in the file.
reads message data for the specified channel from the BLF file and returns a
timetable.bdata
= blfread(blfFile
,chanID
)
reads message data filtered by parameter options for CAN database and message IDs.bdata
= blfread(___,Name,Value
)
Examples
Read Data from BLF File
Read channel 2 message data from a BLF file using a CAN database.
blfData = blfread("Logging_BLF.blf", 2, "Database", canDB)
blfData = 7575×8 timetable
Time ID Extended Name Data Length Signals Error Remote
__________ ____ ________ __________________ ______________________________ ______ ____________ _____ ______
2.2601 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.2801 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.3002 sec 100 false {'EngineData' } {[ 238 2 25 1 0 0 238 2]} 8 {1x1 struct} false false
2.3005 sec 102 false {'EngineDataIEEE'} {[ 0 128 59 68 0 0 0 0]} 8 {1x1 struct} false false
2.3006 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.3008 sec 201 false {'ABSdata' } {[ 0 0 0 0 172 38]} 6 {1x1 struct} false false
2.3009 sec 1020 false {'GearBoxInfo' } {[ 1]} 1 {1x1 struct} false false
2.3201 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.3401 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.3502 sec 100 false {'EngineData' } {[ 4 0 25 2 119 1 238 2]} 8 {1x1 struct} false false
2.3505 sec 102 false {'EngineDataIEEE'} {[53 127 119 64 0 128 187 67]} 8 {1x1 struct} false false
2.3507 sec 201 false {'ABSdata' } {[ 0 0 0 0 35 40]} 6 {1x1 struct} false false
2.3508 sec 1020 false {'GearBoxInfo' } {[ 1]} 1 {1x1 struct} false false
2.3601 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.3801 sec 103 false {'Ignition_Info' } {[ 1 0]} 2 {1x1 struct} false false
2.4002 sec 100 false {'EngineData' } {[ 10 0 25 3 119 1 238 2]} 8 {1x1 struct} false false
⋮
Other forms of the syntax, applying optional filters, look like the following.
data = blfread("myfile.blf",2) candb = canDatabase("testdb.dbc"); data = blfread("myfile.blf", "Database", candb) data = blfread("myfile.blf", "Database", candb, "CANStandardFilter", 1:10) data = blfread("myfile.blf", "Database", candb, "CANExtendedFilter", 3:7) data = blfread("myfile.blf", "Database", candb, "CANStandardFilter", 1:10, ... "CANExtendedFilter", 3:7) data = blfread("myfile.blf", "CANStandardFilter", 1:10, "CANExtendedFilter", 3:7)
Input Arguments
blfFile
— Path to BLF file
string | char
Path to BLF file, specified as a string or character vector. The value can specify a file in the current folder, or a relative or full path name.
Example: "MultipleChannelFile.blf"
Data Types: string
| char
chanID
— Channel ID
numeric
Channel ID, specified as a numeric scalar value, for which to read data from the BLF file. If not specified, all channels are read.
Example: 2
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: "CANStandardFilter",1:8
Database
— CAN database
can.Database
CAN database to use for message decoding, specified as a
can.Database
object.
Example: candb()
CANStandardFilter
— Message standard IDs
numeric array
Message standard IDs, specified as an array of numeric values identifying which messages to import. Message IDs are general, and apply to both CAN and CAN FD bus types. The value can specify a scalar or an array of either a range or noncontiguous IDs. By default, all standard ID messages are imported.
Example: [1:10 45 100:123]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
CANExtendedFilter
— Message extended IDs
numeric array
Message extended IDs, specified as an array of numeric values identifying which messages to import. Message IDs are general, and apply to both CAN and CAN FD bus types. The value can specify a scalar or an array of either a range or noncontiguous IDs. By default, all extended ID messages are imported.
Example: [1 8:10 1001:1080]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
AbsoluteTime
— Return absolute timestamps
false
(default) | true
Return absolute timestamps, specified as true
or
false
. If specified true
, the returned
timetable has absolute timestamps in datetime. If specified false
,
the returned timetable has relative timestamps in duration, elapsed from the initial
timestamp of the file. The default value is false
, to return
relative timestamps.
Example: AbsoluteTime=true
Data Types: logical
TimeRange
— Time interval of data
datetime vector | duration vector
Start time and end time of an interval to read data from, specified as a 2-element
vector. If AbsoluteTime=true
, specify TimeRange
as a datetime vector. If AbsoluteTime=false
(default), specify
TimeRange
as a duration vector. If unspecified, all data samples
are read. You cannot combine this option with IndexRange
.
Example: TimeRange=seconds([0,60])
Data Types: datetime
| duration
IndexRange
— Start and end indices of data to read
numeric vector
Start index and end index of the interval to read data from, specified as a
2-element vector. The indices are inclusive. If unspecified, all data samples are
read. You cannot combine this option with TimeRange
.
Example: IndexRange=[65:128]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
mdata
— Message data from BLF file
cell array of timetables | timetable
Message data from BLF file, returned as a cell array of timetables. If you specify a single channel to read, this returns a timetable.
Version History
Introduced in R2019a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)