Main Content

将时间表数据写入 MDF 文件时自定义元数据

此示例说明在将时间表数据写入 MDF 文件时,如何自定义文件、通道组和通道元数据。

此示例 MDFTimetables.mat 中使用的 MAT 文件包含两个时间表。

  • 时间表 TT1 具有数值数据类型的变量,包括 uint8、uint16、uint32、uint64、int8、int16、int32、int64、single 和 double。

  • 时间表 TT2 具有字符串和字节数组数据类型的变量,包括固定长度和可变长度数据。

在此示例中,将 TT1TT2 中的数据分别写入一个新 MDF 文件的通道组 1 和 2。如果在写入 MDF 文件时需要自定义元数据,请使用此高级工作流。

在继续此示例之前,您应首先了解 MDF 文件结构和示例 将时间表数据写入 MDF 文件的快速入门 中演示的基本工作流。

将时间表加载到工作区

将时间表变量 TT1TT2,从 MDFTimetables.mat 加载到工作区。

load("MDFTimetables.mat")

使用自定义文件元数据新建 MDF 文件

使用不带输入参量的函数 mdfInfo 创建一个包含默认文件元数据的 MDFInfo 对象。请注意,显示的属性表示可设置的文件元数据的子集。

info = mdfInfo
info = 
  MDFInfo with properties:

   File Details
              Author: ""
          Department: ""
             Project: ""
             Subject: ""
             Comment: ""
             Version: "4.20"
    InitialTimestamp: NaT

   Creator Details
     CreatorUserName: ""
      CreatorComment: ""

设置 AuthorComment 属性以提供有关该文件的更多信息。

info.Author = "Alice Author";
info.Comment = "Demonstrate how to set file metadata when creating an MDF file";

Version 从默认值更改为 "4.10"

info.Version = "4.10";

设置 CreatorComment 属性以提供有关该文件创建的更多信息。

info.CreatorComment = "Created using MATLAB for demonstration";

查看更新后的 MDFInfo 对象。

info
info = 
  MDFInfo with properties:

   File Details
              Author: "Alice Author"
          Department: ""
             Project: ""
             Subject: ""
             Comment: "Demonstrate how to set file metadata when creating an MDF file"
             Version: "4.10"
    InitialTimestamp: NaT

   Creator Details
     CreatorUserName: ""
      CreatorComment: "Created using MATLAB for demonstration"

使用带有选项 FileInfo 的函数 mdfCreate 来指定更新后的文件信息对象。这将在磁盘上创建一个新的框架 MDF 文件 TimetableAdvanced.mf4。对自定义字段应用更新后的元数据值,而对其他字段应用默认值。

mdfCreate("TimetableAdvanced.mf4", FileInfo=info)
ans = 
"/tmp/Bdoc24a_2511836_3070643/tp8879c7f7/vnt-ex42503333/TimetableAdvanced.mf4"

检查文件元数据

要确认创建的 MDF 文件具有正确的文件元数据,请使用指定的 MDF 文件名再次调用 mdfInfo,并检查返回的对象。

info1 = mdfInfo("TimetableAdvanced.mf4")
info1 = 
  MDFInfo with properties:

   File Details
                  Name: "TimetableAdvanced.mf4"
                  Path: "/tmp/Bdoc24a_2511836_3070643/tp8879c7f7/vnt-ex42503333/TimetableAdvanced.mf4"
                Author: "Alice Author"
            Department: ""
               Project: ""
               Subject: ""
               Comment: "Demonstrate how to set file metadata when creating an MDF file"
               Version: "4.10"
      InitialTimestamp: 2024-01-26 01:57:10.000000000

   Creator Details
     ProgramIdentifier: "MATLAB"
     CreatorVendorName: "The MathWorks, Inc."
       CreatorToolName: "MATLAB"
    CreatorToolVersion: "24.1.0.2498408 (R2024a) Prerelease Update 3"
       CreatorUserName: ""
        CreatorComment: "Created using MATLAB for demonstration"

   File Contents
            Attachment: [0x7 table]
     ChannelGroupCount: 0

自定义通道组元数据和通道元数据

函数 mdfAddChannelGroupMetadata 将默认或推断的通道组元数据和通道元数据作为自定义属性添加到输入时间表中,并返回生成的时间表。使用此函数可设置默认元数据以作为进一步自定义的基础。

将通道组元数据和通道元数据添加到 TT1,并将生成的时间表赋给新变量 TT1WithMetadata

TT1WithMetadata = mdfAddChannelGroupMetadata(TT1)
TT1WithMetadata=100×10 timetable
     Time      uint8_data    uint16_data    uint32_data    uint64_data    int8_data    int16_data    int32_data    int64_data    single_data    double_data
    _______    __________    ___________    ___________    ___________    _________    __________    __________    __________    ___________    ___________

    0 sec           0            200            600           1400           -99          -198          -396          -794          -9.8           -19.6   
    0.1 sec         2            204            608           1416           -97          -194          -388          -778          -9.6           -19.2   
    0.2 sec         4            208            616           1432           -95          -190          -380          -762          -9.4           -18.8   
    0.3 sec         6            212            624           1448           -93          -186          -372          -746          -9.2           -18.4   
    0.4 sec         8            216            632           1464           -91          -182          -364          -730            -9             -18   
    0.5 sec        10            220            640           1480           -89          -178          -356          -714          -8.8           -17.6   
    0.6 sec        12            224            648           1496           -87          -174          -348          -698          -8.6           -17.2   
    0.7 sec        14            228            656           1512           -85          -170          -340          -682          -8.4           -16.8   
    0.8 sec        16            232            664           1528           -83          -166          -332          -666          -8.2           -16.4   
    0.9 sec        18            236            672           1544           -81          -162          -324          -650            -8             -16   
    1 sec          20            240            680           1560           -79          -158          -316          -634          -7.8           -15.6   
    1.1 sec        22            244            688           1576           -77          -154          -308          -618          -7.6           -15.2   
    1.2 sec        24            248            696           1592           -75          -150          -300          -602          -7.4           -14.8   
    1.3 sec        26            252            704           1608           -73          -146          -292          -586          -7.2           -14.4   
    1.4 sec        28            256            712           1624           -71          -142          -284          -570            -7             -14   
    1.5 sec        30            260            720           1640           -69          -138          -276          -554          -6.8           -13.6   
      ⋮

检查新时间表的自定义属性。请注意,属性 ChannelTypeChannelDataTypeChannelNumBits 的值是由 mdfAddChannelGroupMetadata 根据存储在对应时间表变量中的数据推断得出的。其余属性设置为默认值。

显示的前三个属性是应用于整个时间表的元数据,其余属性是应用于每个变量的元数据。一个时间表表示一个通道组,该时间表中的一个变量表示一个通道;然后前三个属性表示通道组元数据,其余属性表示通道元数据。

TT1WithMetadata.Properties.CustomProperties
ans = 
CustomProperties with properties:

           ChannelGroupAcquisitionName: ""
                   ChannelGroupComment: ""
                ChannelGroupSourceName: ""
                ChannelGroupSourcePath: ""
             ChannelGroupSourceComment: ""
                ChannelGroupSourceType: Unspecified
             ChannelGroupSourceBusType: Unspecified
    ChannelGroupSourceBusChannelNumber: 0
                    ChannelDisplayName: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                        ChannelComment: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                           ChannelUnit: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                           ChannelType: [FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength]
                       ChannelDataType: [IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerSignedLittleEndian    ...    ] (1x10 asam.mdf.ChannelDataType)
                        ChannelNumBits: [8 16 32 64 8 16 32 64 32 64]
                  ChannelComponentType: [None    None    None    None    None    None    None    None    None    None]
                ChannelCompositionType: [None    None    None    None    None    None    None    None    None    None]
                     ChannelSourceName: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                     ChannelSourcePath: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                  ChannelSourceComment: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                     ChannelSourceType: [Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified]
                  ChannelSourceBusType: [Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified]
         ChannelSourceBusChannelNumber: [0 0 0 0 0 0 0 0 0 0]
                     ChannelReadOption: [Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing]

设置时间表的属性 ChannelGroupComment,从而提供有关此通道组的详细信息。

TT1WithMetadata.Properties.CustomProperties.ChannelGroupComment = "This channel group contains numeric data of various types.";

为时间表中的每个变量设置属性 ChannelComment,从而提供有关每个通道的详细信息。您可以使用变量索引或变量名称对 ChannelComment 属性进行索引。

TT1WithMetadata.Properties.CustomProperties.ChannelComment(1) = "Unsigned 8-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment(2) = "Unsigned 16-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment(3) = "Unsigned 32-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment(4) = "Unsigned 64-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment("int8_data") = "Signed 8-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment("int16_data") = "Signed 16-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment("int32_data") = "Signed 32-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment("int64_data") = "Signed 64-bit integer";
TT1WithMetadata.Properties.CustomProperties.ChannelComment(9) = "32-bit floating-point number";
TT1WithMetadata.Properties.CustomProperties.ChannelComment(10) = "64-bit floating-point number";

查看通道组和通道的更新后的元数据。

TT1WithMetadata.Properties.CustomProperties
ans = 
CustomProperties with properties:

           ChannelGroupAcquisitionName: ""
                   ChannelGroupComment: "This channel group contains numeric data of various types."
                ChannelGroupSourceName: ""
                ChannelGroupSourcePath: ""
             ChannelGroupSourceComment: ""
                ChannelGroupSourceType: Unspecified
             ChannelGroupSourceBusType: Unspecified
    ChannelGroupSourceBusChannelNumber: 0
                    ChannelDisplayName: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                        ChannelComment: ["Unsigned 8-bit integer"    "Unsigned 16-bit integer"    "Unsigned 32-bit integer"    "Unsigned 64-bit integer"    "Signed 8-bit integer"    "Signed 16-bit integer"    ...    ] (1x10 string)
                           ChannelUnit: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                           ChannelType: [FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength    FixedLength]
                       ChannelDataType: [IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerUnsignedLittleEndian    IntegerSignedLittleEndian    ...    ] (1x10 asam.mdf.ChannelDataType)
                        ChannelNumBits: [8 16 32 64 8 16 32 64 32 64]
                  ChannelComponentType: [None    None    None    None    None    None    None    None    None    None]
                ChannelCompositionType: [None    None    None    None    None    None    None    None    None    None]
                     ChannelSourceName: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                     ChannelSourcePath: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                  ChannelSourceComment: [""    ""    ""    ""    ""    ""    ""    ""    ""    ""]
                     ChannelSourceType: [Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified]
                  ChannelSourceBusType: [Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified    Unspecified]
         ChannelSourceBusChannelNumber: [0 0 0 0 0 0 0 0 0 0]
                     ChannelReadOption: [Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing    Missing]

同样,将通道组元数据和通道元数据添加到 TT2,并将生成的时间表赋给新变量 TT2WithMetadata

TT2WithMetadata = mdfAddChannelGroupMetadata(TT2)
TT2WithMetadata=10×4 timetable
    Time     fixed_length_string_data    fixed_length_byte_array_data    variable_length_string_data    variable_length_byte_array_data
    _____    ________________________    ____________________________    ___________________________    _______________________________

    0 sec             "abcd"               {[255 255 255 255 255]}                 "zero"                   {[            255 255]}    
    1 sec             "efgh"               {[     18 35 52 69 86]}                 "one"                    {[     18 35 52 69 86]}    
    2 sec             "ijkl"               {[          0 1 2 3 4]}                 "two"                    {[    0 1 2 3 4 5 6 7]}    
    3 sec             "mnop"               {[          4 3 2 1 0]}                 "three"                  {[          4 3 2 1 0]}    
    4 sec             "qrst"               {[255 254 253 252 251]}                 "four"                   {[        253 252 251]}    
    5 sec             "uvwx"               {[250 249 248 247 246]}                 "five"                   {[250 249 248 247 246]}    
    6 sec             "yzAB"               {[245 244 243 242 241]}                 "six"                    {[245 244 243 242 241]}    
    7 sec             "CDEF"               {[240 239 238 237 236]}                 "seven"                  {[        240 238 236]}    
    8 sec             "GHIJ"               {[235 234 233 232 231]}                 "eight"                  {[        235 233 231]}    
    9 sec             "KLMN"               {[255 255 255 255 255]}                 "nine"                   {[255 255 255 255 255]}    

检查新时间表的自定义属性。

TT2WithMetadata.Properties.CustomProperties
ans = 
CustomProperties with properties:

           ChannelGroupAcquisitionName: ""
                   ChannelGroupComment: ""
                ChannelGroupSourceName: ""
                ChannelGroupSourcePath: ""
             ChannelGroupSourceComment: ""
                ChannelGroupSourceType: Unspecified
             ChannelGroupSourceBusType: Unspecified
    ChannelGroupSourceBusChannelNumber: 0
                    ChannelDisplayName: [""    ""    ""    ""]
                        ChannelComment: [""    ""    ""    ""]
                           ChannelUnit: [""    ""    ""    ""]
                           ChannelType: [FixedLength    FixedLength    VariableLength    VariableLength]
                       ChannelDataType: [StringASCII    ByteArray    StringASCII    ByteArray]
                        ChannelNumBits: [40 40 64 64]
                  ChannelComponentType: [None    None    None    None]
                ChannelCompositionType: [None    None    None    None]
                     ChannelSourceName: [""    ""    ""    ""]
                     ChannelSourcePath: [""    ""    ""    ""]
                  ChannelSourceComment: [""    ""    ""    ""]
                     ChannelSourceType: [Unspecified    Unspecified    Unspecified    Unspecified]
                  ChannelSourceBusType: [Unspecified    Unspecified    Unspecified    Unspecified]
         ChannelSourceBusChannelNumber: [0 0 0 0]
                     ChannelReadOption: [Missing    Missing    Missing    Missing]

设置时间表属性 ChannelGroupComment,,从而提供有关此通道组的详细信息。

TT2WithMetadata.Properties.CustomProperties.ChannelGroupComment = "This channel group contains string and byte array data of both fixed and variable length.";

为时间表中的每个变量设置属性 ChannelComment,从而提供有关每个通道的详细信息。

TT2WithMetadata.Properties.CustomProperties.ChannelComment(1) = "String data where each sample has the same number of characters";
TT2WithMetadata.Properties.CustomProperties.ChannelComment(2) = "Byte array data where each sample has the same number of bytes";
TT2WithMetadata.Properties.CustomProperties.ChannelComment(3) = "String data where samples have varying numbers of characters";
TT2WithMetadata.Properties.CustomProperties.ChannelComment(4) = "Byte array data where samples have varying numbers of bytes";

查看通道组和通道的更新后的元数据。

TT2WithMetadata.Properties.CustomProperties
ans = 
CustomProperties with properties:

           ChannelGroupAcquisitionName: ""
                   ChannelGroupComment: "This channel group contains string and byte array data of both fixed and variable length."
                ChannelGroupSourceName: ""
                ChannelGroupSourcePath: ""
             ChannelGroupSourceComment: ""
                ChannelGroupSourceType: Unspecified
             ChannelGroupSourceBusType: Unspecified
    ChannelGroupSourceBusChannelNumber: 0
                    ChannelDisplayName: [""    ""    ""    ""]
                        ChannelComment: ["String data where each sample has the same number of characters"    "Byte array data where each sample has the same number of bytes"    ...    ] (1x4 string)
                           ChannelUnit: [""    ""    ""    ""]
                           ChannelType: [FixedLength    FixedLength    VariableLength    VariableLength]
                       ChannelDataType: [StringASCII    ByteArray    StringASCII    ByteArray]
                        ChannelNumBits: [40 40 64 64]
                  ChannelComponentType: [None    None    None    None]
                ChannelCompositionType: [None    None    None    None]
                     ChannelSourceName: [""    ""    ""    ""]
                     ChannelSourcePath: [""    ""    ""    ""]
                  ChannelSourceComment: [""    ""    ""    ""]
                     ChannelSourceType: [Unspecified    Unspecified    Unspecified    Unspecified]
                  ChannelSourceBusType: [Unspecified    Unspecified    Unspecified    Unspecified]
         ChannelSourceBusChannelNumber: [0 0 0 0]
                     ChannelReadOption: [Missing    Missing    Missing    Missing]

使用自定义通道组元数据和通道元数据将数据写入 MDF 文件

现在,TT1WithMetadata 携带要写入通道组 1 的数据,并且携带要为此通道组及其通道配置的元数据。TT2WithMetadata 同样如此。

使用 mdfWrite 将具有自定义元数据的两个时间表写入在前面的步骤中创建的框架文件 TimetableAdvanced.mf4

mdfWrite("TimetableAdvanced.mf4", TT1WithMetadata)
mdfWrite("TimetableAdvanced.mf4", TT2WithMetadata)

检查通道组元数据

使用 mdfChannelGroupInfo 检查写入 TimetableAdvanced.mf4 的两个通道组的元数据。

chanGrpInfo = mdfChannelGroupInfo("TimetableAdvanced.mf4")
chanGrpInfo=2×13 table
    GroupNumber    AcquisitionName                                             Comment                                             NumSamples    DataSize    Sorted    SourceName     SourcePath     SourceComment    SourceType     SourceBusType    SourceBusChannelNumber    SourceSimulated
    ___________    _______________    _________________________________________________________________________________________    __________    ________    ______    ___________    ___________    _____________    ___________    _____________    ______________________    _______________

         1           <undefined>      This channel group contains numeric data of various types.                                      100          5000      true      <undefined>    <undefined>     <undefined>     Unspecified     Unspecified               0                    false     
         2           <undefined>      This channel group contains string and byte array data of both fixed and variable length.        10           340      true      <undefined>    <undefined>     <undefined>     Unspecified     Unspecified               0                    false     

检查通道元数据

使用 mdfChannelInfo 检查通道组 1 中通道的元数据。将 AdditionalMetadata 选项指定为 true 可以查看其他元数据。

chanGrp1Info = mdfChannelInfo("TimetableAdvanced.mf4", GroupNumber=1, AdditionalMetadata=true)
chanGrp1Info=11×25 table
        Name         GroupNumber    GroupNumSamples    GroupAcquisitionName                           GroupComment                           GroupSourceName    GroupSourcePath    DisplayName       Unit                  Comment               ExtendedNamePrefix    SourceName     SourcePath        Type        SyncType             DataType              NumBits    ComponentType    CompositionType    ConversionType    SourceComment    SourceType     SourceBusType    SourceBusChannelNumber    SourceSimulated
    _____________    ___________    _______________    ____________________    __________________________________________________________    _______________    _______________    ___________    ___________    ____________________________    __________________    ___________    ___________    ___________    ________    ___________________________    _______    _____________    _______________    ______________    _____________    ___________    _____________    ______________________    _______________

    "Time"                1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         s              <undefined>                        <undefined>        <undefined>    <undefined>    Master           Time      RealLittleEndian                 64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "double_data"         1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    64-bit floating-point number       <undefined>        <undefined>    <undefined>    FixedLength      None      RealLittleEndian                 64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "int16_data"          1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Signed 16-bit integer              <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerSignedLittleEndian        16           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "int32_data"          1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Signed 32-bit integer              <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerSignedLittleEndian        32           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "int64_data"          1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Signed 64-bit integer              <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerSignedLittleEndian        64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "int8_data"           1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Signed 8-bit integer               <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerSignedLittleEndian         8           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "single_data"         1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    32-bit floating-point number       <undefined>        <undefined>    <undefined>    FixedLength      None      RealLittleEndian                 32           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "uint16_data"         1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Unsigned 16-bit integer            <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerUnsignedLittleEndian      16           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "uint32_data"         1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Unsigned 32-bit integer            <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerUnsignedLittleEndian      32           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "uint64_data"         1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Unsigned 64-bit integer            <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerUnsignedLittleEndian      64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "uint8_data"          1               100              <undefined>         This channel group contains numeric data of various types.      <undefined>        <undefined>          ""         <undefined>    Unsigned 8-bit integer             <undefined>        <undefined>    <undefined>    FixedLength      None      IntegerUnsignedLittleEndian       8           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     

同样,检查通道组 2 中通道的元数据。

chanGrp2Info = mdfChannelInfo("TimetableAdvanced.mf4", GroupNumber=2, AdditionalMetadata=true)
chanGrp2Info=5×25 table
                  Name                   GroupNumber    GroupNumSamples    GroupAcquisitionName                                          GroupComment                                           GroupSourceName    GroupSourcePath    DisplayName       Unit                                    Comment                                ExtendedNamePrefix    SourceName     SourcePath          Type         SyncType        DataType        NumBits    ComponentType    CompositionType    ConversionType    SourceComment    SourceType     SourceBusType    SourceBusChannelNumber    SourceSimulated
    _________________________________    ___________    _______________    ____________________    _________________________________________________________________________________________    _______________    _______________    ___________    ___________    _______________________________________________________________    __________________    ___________    ___________    ______________    ________    ________________    _______    _____________    _______________    ______________    _____________    ___________    _____________    ______________________    _______________

    "Time"                                    2               10               <undefined>         This channel group contains string and byte array data of both fixed and variable length.      <undefined>        <undefined>          ""         s              <undefined>                                                           <undefined>        <undefined>    <undefined>    Master              Time      RealLittleEndian      64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "fixed_length_byte_array_data"            2               10               <undefined>         This channel group contains string and byte array data of both fixed and variable length.      <undefined>        <undefined>          ""         <undefined>    Byte array data where each sample has the same number of bytes        <undefined>        <undefined>    <undefined>    FixedLength         None      ByteArray             40           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "fixed_length_string_data"                2               10               <undefined>         This channel group contains string and byte array data of both fixed and variable length.      <undefined>        <undefined>          ""         <undefined>    String data where each sample has the same number of characters       <undefined>        <undefined>    <undefined>    FixedLength         None      StringASCII           40           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "variable_length_byte_array_data"         2               10               <undefined>         This channel group contains string and byte array data of both fixed and variable length.      <undefined>        <undefined>          ""         <undefined>    Byte array data where samples have varying numbers of bytes           <undefined>        <undefined>    <undefined>    VariableLength      None      ByteArray             64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     
    "variable_length_string_data"             2               10               <undefined>         This channel group contains string and byte array data of both fixed and variable length.      <undefined>        <undefined>          ""         <undefined>    String data where samples have varying numbers of characters          <undefined>        <undefined>    <undefined>    VariableLength      None      StringASCII           64           None              None           Unspecified           ""          Unspecified     Unspecified               0                    false     

检查数据

要验证数据是否已成功写入文件,请使用 mdfRead 从两个通道组读取数据并检查结果。

data = mdfRead("TimetableAdvanced.mf4")
data=2×1 cell array
    {100x10 timetable}
    { 10x4  timetable}

chanGrp1Data = data{1}
chanGrp1Data=100×10 timetable
     Time      uint8_data    uint16_data    uint32_data    uint64_data    int8_data    int16_data    int32_data    int64_data    single_data    double_data
    _______    __________    ___________    ___________    ___________    _________    __________    __________    __________    ___________    ___________

    0 sec           0            200            600           1400           -99          -198          -396          -794          -9.8           -19.6   
    0.1 sec         2            204            608           1416           -97          -194          -388          -778          -9.6           -19.2   
    0.2 sec         4            208            616           1432           -95          -190          -380          -762          -9.4           -18.8   
    0.3 sec         6            212            624           1448           -93          -186          -372          -746          -9.2           -18.4   
    0.4 sec         8            216            632           1464           -91          -182          -364          -730            -9             -18   
    0.5 sec        10            220            640           1480           -89          -178          -356          -714          -8.8           -17.6   
    0.6 sec        12            224            648           1496           -87          -174          -348          -698          -8.6           -17.2   
    0.7 sec        14            228            656           1512           -85          -170          -340          -682          -8.4           -16.8   
    0.8 sec        16            232            664           1528           -83          -166          -332          -666          -8.2           -16.4   
    0.9 sec        18            236            672           1544           -81          -162          -324          -650            -8             -16   
    1 sec          20            240            680           1560           -79          -158          -316          -634          -7.8           -15.6   
    1.1 sec        22            244            688           1576           -77          -154          -308          -618          -7.6           -15.2   
    1.2 sec        24            248            696           1592           -75          -150          -300          -602          -7.4           -14.8   
    1.3 sec        26            252            704           1608           -73          -146          -292          -586          -7.2           -14.4   
    1.4 sec        28            256            712           1624           -71          -142          -284          -570            -7             -14   
    1.5 sec        30            260            720           1640           -69          -138          -276          -554          -6.8           -13.6   
      ⋮

chanGrp2Data = data{2}
chanGrp2Data=10×4 timetable
    Time     fixed_length_string_data    fixed_length_byte_array_data    variable_length_string_data    variable_length_byte_array_data
    _____    ________________________    ____________________________    ___________________________    _______________________________

    0 sec             "abcd"               {[255 255 255 255 255]}                 "zero"                   {[            255 255]}    
    1 sec             "efgh"               {[     18 35 52 69 86]}                 "one"                    {[     18 35 52 69 86]}    
    2 sec             "ijkl"               {[          0 1 2 3 4]}                 "two"                    {[    0 1 2 3 4 5 6 7]}    
    3 sec             "mnop"               {[          4 3 2 1 0]}                 "three"                  {[          4 3 2 1 0]}    
    4 sec             "qrst"               {[255 254 253 252 251]}                 "four"                   {[        253 252 251]}    
    5 sec             "uvwx"               {[250 249 248 247 246]}                 "five"                   {[250 249 248 247 246]}    
    6 sec             "yzAB"               {[245 244 243 242 241]}                 "six"                    {[245 244 243 242 241]}    
    7 sec             "CDEF"               {[240 239 238 237 236]}                 "seven"                  {[        240 238 236]}    
    8 sec             "GHIJ"               {[235 234 233 232 231]}                 "eight"                  {[        235 233 231]}    
    9 sec             "KLMN"               {[255 255 255 255 255]}                 "nine"                   {[255 255 255 255 255]}