This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Map Data Using Root Inport Mapper Tool

Use the Root Inport Mapper tool to import, visualize, and map signal and bus data to root-level inports.

Root-level inport mapping imports signal data meets most modeling requirements and maintains model flexibility.

  • Test your model with signals from the workspace and use your model as a referenced model in a larger context without any modification. Test signals in your model without disconnecting the inports and connecting sources to them.

  • Use the Root Inport Mapper tool to update the Input parameter based on the signal data that you import and map to root-level inports.

  • Visually inspect signal data without loading all the signal data into MATLAB® memory.

To use the Root Inport Mapper tool:

  1. Create signal data in the MATLAB workspace.

  2. For a Simulink® model, import the data from the workspace. You can visualize the data you import.

  3. Map the data to root-level inports.

  4. Simulate the model.

  5. Save the Root Inport Mapper scenario.

The Model

This model has three root-level Inport blocks. Two of the Inport blocks output scalar signals and the other Inport block outputs bus data. Open the model.

This example shows how you can use the Root Inport Mapper tool to test the model with data. This approach can be useful for performing standalone testing of a model that another model references.

Create Signal Data

You can define the signal data as MATLAB timeseries objects.

  1. Define the time values for the signal data.

    sampleTime = 0.01;
    endTime = 10;
    numberOfSamples = endTime * 1/sampleTime +1;
    timeVector = (0:numberOfSamples) * sampleTime;
  2. Create the data for the two scalar signals. Naming the data variable to match the name of the corresponding signal makes it easier to map data to signals.

    signal_1 = timeseries(sin(timeVector)*10,timeVector);
    signal_2 = timeseries(rand(size(timeVector)),timeVector);
  3. Create the signals for the bus.

    busSignal.busElement_1 = timeseries(cos(timeVector)*2,timeVector);
    busSignal.busElement_2 = timeseries(randn(size(timeVector)),timeVector);
  4. Create the bus object for the output data type of the Bus_1 Inport block. You can create the bus object from the bus signal that you defined. Use a bus object for bus signals that cross model reference boundaries.

    busInfo = Simulink.Bus.createObject(busSignal);

Import and Visualize Workspace Signal Data

Import the signal data that you created from the workspace into the Root Inport Mapper tool. Then you can use the tool to visualize the imported data.

  1. Open the Root Inport Mapper tool. Open the Block Parameters dialog box for one of the Inport blocks in the model and click Connect Input.

  2. In the Root Inport Mapper tool, select the From Workspace button.

  3. In the Import dialog box, specify a MAT-file to save signals to. For this example, use the default.

  4. Click the Name check box to clear the data variables. Then click the check boxes for the busSignal, signal_1, and signal_2 signals.

    Although in this example you select all the signals, you can select a subset of signals.

  5. Leave the Convert signals into a scenario dataset and save to MAT-file check box enabled and click OK.

  6. You can visualize signals. In the Root Inport Mapper dialog box toolbar, click Signals > Preview Signals.

    The Preview tab appears. You can select signals to plot. For example, to see a plot of signal_1, in the Navigation pane, expand the scenario data set (in this example, the top node, untitled) and then expand the signal_1 entry. Select the check box for signal_1(1,1,:) to plot the data.

  7. Close the Preview tab by clicking the Close Signal Preview button.

Map the Data to Inports

After you import the data, you map which data to use for specific Inport blocks.

  1. Select the map mode, which specifies the criteria the mapping uses. In the toolbar, select the Signal Name radio button.

    The signals in this model have names, so mapping based on signal names makes it very clear which data is going to an Inport block.

  2. You can specify options for the mapping. In the toolbar, select Options. Select Update Model, which updates the model after you do the mapping. Compiling the model verifies that signal dimensions and data types match between the data and the Inport blocks.

  3. Map the data. In the Navigation pane, select the scenario data set. In the toolbar, click Map to Model. The dialog box shows the mapped data.

Save the Mapping and Data

If you want to reuse the mapping and data that you have set up, you can save it as a scenario. In the Root Inport Mapper tool, click Save > Save As and save the scenario as an .mldatx file.

Simulate the Model

  1. In the Navigation pane, select the scenario data set.

  2. In the toolbar, click Mark for Simulation.

    The model is now set up to simulate using the workspace signal data that you mapped to root-level Inport blocks.

  3. Simulate the model.

    This model includes a Dashboard block that shows the data used during simulation for signal_1. The plot matches the plot you did when you visualized the data as part of the data import process.

Related Examples

More About

Was this topic helpful?