Main Content

blfread

Read data from Vector BLF file

Description

mdata = blfread(blfFile) reads all the data from the specified BLF file and returns a cell array of timetables to the variable bdata. The index of each element in the cell array corresponds to the channel number of the data in the file.

bdata = blfread(blfFile,chanID) reads message data for the specified channel from the BLF file and returns a timetable.

bdata = blfread(___,Name,Value) reads message data filtered by parameter options for CAN database and message IDs.

example

Examples

collapse all

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

collapse all

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

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

CAN database to use for message decoding, specified as a can.Database object.

Example: candb()

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

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

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

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

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

collapse all

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