主要内容

mbcmodel.CreateData

Create data object

Syntax

DataObj = mbcmodel.CreateData()
DataObj = mbcmodel.CreateData(Filename, FileType,sheetName)
DataObj = mbcmodel.CreateData(Table)
DataObj = mbcmodel.CreateData(mbcStruct)

Description

DataObj = mbcmodel.CreateData() creates an empty data object. The data object is not associated with an MBC project. The data object becomes associated with a project when you fit a model to data using the mbcmodel.testplan object function, AttachData. If you want to load data into a project use the mbcmodel.project object function, CreateData.

DataObj = mbcmodel.CreateData(Filename, FileType,sheetName) creates a data object and imports data from the file specified by Filename, optionally specify the file type using Filetype or if importing from an Excel file specify the sheet name using sheetName.

DataObj = mbcmodel.CreateData(Table) creates a data object and imports data from the table object specified by Table.

DataObj = mbcmodel.CreateData(mbcStruct) creates a data object and imports data from the MBC data structure specified by MBCDataStructure.

Input Arguments

expand all

If you do not specify a Filename, no data is loaded into the new data object. Load data using ImportFromFile, provided that you enable editing of the data object by using BeginEdit. Call CommitEdit to apply edits.

If you create the data object specifying a filename, then the Name property is set to the filename. However, if you use ImportFromFile after creation to load data from a file, the name of the data object does not change.

Data Types: char | string

Table object.

Data Types: table

Character vector specifying the file type. See DataFileTypes for the specification of allowed file types. If filetype is not provided, the software infers the file type from the file extension.

Data Types: char | string

Name of excel sheet to import, specified as a character vector.

Data Types: char | string

An MBC data structure is a structure array that contains these fields:

  • varNames — Cell array of character vectors that hold the names of the variables in the data (1xn or nx1).

  • varUnits — Cell array of character vectors that hold the units associated with the variables in varNames (1xn or nx1). If array is empty, no units are defined.

  • data — Array that holds the values of the variables (mxn).

  • comment — Optional character vector holding comment information about the data.

Output Arguments

expand all

Data object, returned as a mbcmodel.data object.

Examples

expand all

Load data from an excel file.

file = fullfile(matlabroot, 'toolbox', ...
                'mbc', 'mbctraining', 'holliday.xlsx');
data = mbcmodel.CreateData(file);
data = 

  data with properties:

              Name: 'holliday'
        NumRecords: 270
        NumSignals: 7
          NumTests: 27
    RecordsPerTest: [10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10]
        IsEditable: 1
     IsBeingEdited: 0
             Owner: []
       SignalNames: [7×1 string]
       SignalUnits: [7×1 string]
           Filters: [0×0 struct]
       TestFilters: [0×0 struct]
     UserVariables: [0×0 struct]

Version History

Introduced before R2006a