Products & Services Solutions Academia Support User Community Company

Learn more about SimBiology   

Importing Data

Supported Files and Data Types

To be able to fit data to a model, the data must be in a dataset array, constructed by the dataset function. You can construct the dataset array at the command line, or import the data into the SimBiology desktop which constructs the dataset array for you.

Unit Conversion

Regardless of whether unit conversion functionality is on or off, dosing in the data file must be expressed in amounts (or as amount/time for infusion rate). By default Unit Conversion is off, so you must ensure that units for the data are consistent with each other. If you want to turn on unit conversion, see Unit Conversion for Imported Data and the Model.

Importing Data at the Command Line

Use the dataset function to import tabular data with named columns into an array that you can use in fitting and analysis at the command line. The dataset function lets you specify parameter/value pair arguments in which you can specify options such as the type of delimiter, and whether the first row contains header names. See dataset for more information.

Examples

% text files
data = dataset('file', 'Theophylline.txt', 'TreatAsEmpty', '.')
% For Excel files
data = dataset('xlsfile', 'Theophylline.xls', 'TreatAsEmpty', '')

You can also construct the dataset array from variables in the MATLAB Workspace.

% Create a 10x2 array
x = rand(10,2);
% Construct a dataset array containing x
data = dataset({x(:, 1), 'Column1'}, {x(:,2), 'Column2'})

If you import the data as separate variables containing doubles, you can construct the dataset array by concatenating the variables.

% Create 2 10x1 vectors 
x = rand(10,1);
y = rand(10,1);
% Construct a dataset array containing x and y
data = dataset({x, 'Column1'}, {y, 'Column2'})

After you finish analyzing your data, you might have created new variables. You can export these variables to a variety of file formats. The Exporting Data section of the MATLAB documentation describes how to export data from the MATLAB Workspace.

Other Resources for Importing Data

The Importing Data section of the MATLAB documentation provides detailed information about supported data formats and the functions for importing data into the MATLAB Workspace. You can also import data using the MATLAB Import Wizard (see Using the Import Wizard in the MATLAB documentation). With the Import Wizard, you can import data as text files, such as .txt and .dat, MAT-files, and spreadsheet files, such as .xls.

The MATLAB Import Wizard processes the data source and recognizes data delimiters, as well as row or column headers, to facilitate the process of data selection and import into the MATLAB Workspace. You can import the data into the SimBiology desktop from the MATLAB Workspace.

Data Import in the SimBiology Desktop

In the SimBiology desktop, the import process constructs the dataset array for you, using one of the following:

During import, you can specify whether the first row contains header information, and whether any characters in the file should be interpreted as missing values. You can also edit column headings and see a preview of the data (first 20 rows).

Tips for Importing Data from Text Files or Excel Spreadsheets

Use the following tips to prepare the data before importing. This helps the import process to construct the dataset array in the SimBiology desktop.

Importing Data from the MATLAB Workspace into the SimBiology Desktop

If you have already imported data into MATLAB, you can either continue to work at the command line or import the data into the SimBiology desktop for analysis. For information on when to use the command line or the desktop, see Using the Command Line Versus the SimBiology Desktop.

  1. If the SimBiology desktop is not open, at the MATLAB command line type:

    simbiology
  2. Select File > Add Data > From MATLAB Workspace. The MATLAB Workspace Import dialog box opens with a list of variables that contain the accepted data types, and a preview of the data.

  3. In the MATLAB Workspace Variables table, select the variables to import.

    • If the Data Type of the variable you wish to import is dataset, time series, or SimData object, you can select one variable containing the object.

    • If the Data Type of the variable you wish to import is double, you can select multiple variables to create the data set. Note the following:

      • The variables must each contain the same number of rows.

      • During import, the selected variables are concatenated column-wise.

      • The variables are concatenated in the order that they appear in the table, from top to bottom resulting in columns ordered from left to right.

      • If necessary, a matrix is transposed to create a matrix with compatible size.

      The Size column shows the number of rows x number of columns in the variable.

    If your data file contains missing values, the Data Preview table shows the missing values as NaN.

  4. Double-click the cells in the first row of the Data Preview table to edit the names of the column headers.

      Note   After the data is imported into the SimBiology desktop, you cannot rename the headers.

    The SimBiology desktop uses the names you specify in the column headers to:

    • Identify columns containing data used in fitting

    • Plot one variable against another during data exploration

    • Identify names in expressions when working with your data

  5. Click OK. The SimBiology desktop adds the data to the Project Explorer under External Data, and opens the pane containing the data.

  6. (Optional) Rename the pane containing the imported data set, in the Project Explorer:

    1. Right-click the item representing the data set and select Rename Data. The Rename Data Set dialog box opens.

    2. Specify a name for the data set and click Save.

Importing Data from a Text File into the SimBiology Desktop

  1. If the SimBiology desktop is not open, at the MATLAB command line type:

    simbiology
  2. Select File > Add Data > From File. The Import Data from File dialog box opens.

  3. Select a .txt file and click Open. The Text File Import dialog box opens. This dialog box lets you preview the data.

  4. Under Column Separator, select the type of separator in the text file:

    • Select Auto-detect to let the SimBiology desktop detect and choose the separator.

    • If Auto-detect does not select the correct option, select one of the following options:

      Comma
      Space
      Semicolon
      Tab
      Other

      If you select Other, enter a character that represents the column separator.

  5. If your data file does not contain header information in the first row, clear the First row contains header information check box.

  6. If your data file contains missing values, specify the character used to identify missing values in the file. The Data Preview table shows missing values as NaN.

  7. Double-click the cells in the first row of the Data Preview table to edit the names of the column headers.

      Note   After the data is imported into the SimBiology desktop you cannot rename the headers.

    The SimBiology desktop uses the names you specify in the column headers to:

    • Identify columns containing data used in fitting

    • Plot one variable against another during data exploration

    • Identify names in expressions when working with your data

  8. Click OK. The SimBiology desktop adds the data to the Project Explorer under External Data, and opens the pane containing the data.

  9. (Optional) Rename the pane containing the imported data set, in the Project Explorer:

    1. Right-click the item representing the data set and select Rename Data. The Rename Data Set dialog box opens.

    2. Specify a name for the data set and click Save.

Importing Data from an Excel File into the SimBiology Desktop

  1. If the SimBiology desktop is not open, at the MATLAB command line type:

    simbiology
  2. Select File > Add Data > From File. The Import Data from File dialog box opens.

  3. Select a .xls file and click Open. The Excel File Import dialog box opens. This dialog box lets you preview the data.

  4. If your data file does not contain header information in the first row, clear the First row contains header information check box.

    If your data file contains missing values, the Data Preview table shows missing values as NaN.

  5. Double-click the cells in the first row of the Data Preview table to edit the names of the column headers.

      Note   After the data is imported into the SimBiology desktop you cannot rename the headers.

    The SimBiology desktop uses the names you specify in the column headers to:

    • Identify columns containing data used in fitting

    • Plot one variable against another during data exploration

    • Identify names in expressions when working with your data

  6. Click OK. The SimBiology desktop adds the data to the Project Explorer under External Data, and opens the pane containing the data.

  7. (Optional) Rename the pane containing the imported data set, in the Project Explorer:

    1. Right-click the item representing the data set and select Rename Data. The Rename Data Set dialog box opens.

    2. Specify a name for the data set and click Save.

Importing Data from a MAT-File into the SimBiology Desktop

  1. If the SimBiology desktop is not open, at the MATLAB command line type:

    simbiology
  2. Select File > Add Data > From File. The Import Data from File dialog box opens.

  3. Select a .mat file and click Open. The MAT File Import dialog box opens with a list of the importable variables in the MAT-file along with their data type and size.

  4. In the MAT-file Variables table, select the variables to import.

    • If the Data Type of the variable you wish to import is dataset, time series, or SimData object, you can select one variable containing the object.

    • If the Data Type of the variable you wish to import is double, you can select multiple variables to create the data set. Note the following:

      • The variables must each contain the same number of rows.

      • During import, the selected variables are concatenated column-wise.

      • The variables are concatenated in the order that they appear in the table, from top to bottom resulting in columns ordered from left to right.

      • If necessary, a matrix is transposed to create a matrix with compatible size.

      The Size column shows the number of rows x number of columns in the variable.

    If your data file contains missing values, the Data Preview table shows missing values as NaN.

  5. Double-click the cells in the first row of the Data Preview table to edit the names of the column headers.

      Note   After the data is imported into the SimBiology desktop you cannot rename the headers.

    The SimBiology desktop uses the names you specify in the column headers to:

    • Identify columns containing data used in fitting

    • Plot one variable against another during data exploration

    • Identify names in expressions when working with your data

  6. Click OK. The SimBiology desktop adds the data to the Project Explorer under External Data, and opens the pane containing the data.

  7. (Optional) To rename the pane containing the imported data set, in the Project Explorer, right-click the item representing the data set and select Rename Data. The Rename Data Set dialog box opens.

  8. Specify a name for the data set and click Save.

Resources for Working with Imported Data

See the following sections for help on working with data in the SimBiology desktop.

For information on ...See ...
Identifying group and independent variablesIdentifying Group and Independent Variables in the Data
Plotting data Visualizing Data Using Plots in the SimBiology Desktop
Cleaning up the imported dataExcluding Rows of Data
Calculating statisticsCalculating Statistics for Imported Data

See the following sections for help with creating models and fitting data at the command line or the desktop

For information on ...See ...
Creating PK models

Fitting data

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS