Define and Update Inport Data

You can create root-level input ports and use Root Inport Mapper to define input data. You can update the input data without rebuilding the model by using MATLAB® language.

File Dependencies

This procedure depends on the following files:

Before starting this procedure, navigate to a working folder.

Map Inport to Use Square Wave

  1. Open model ex_slrt_inport_osc and save a copy to a working folder.

  2. Load ex_slrt_inport_square.mat and assign square to a temporary workspace variable for use with Root Inport Mapper.

    waveform = square;
  3. Double-click input port In1.

  4. Clear Interpolate data, and then click Connect Input.

  5. In Root Inport Mapper, click From Workspace and select variable waveform. Clear the other variables.

  6. In the Save to text box, enter a name such as ex_slrt_inport_waveform_osc.mat, and then click OK.

  7. Select map to model option Port order and, in the Options menu, select Update Model.

  8. Click Map to Model.

  9. To update the model with the mapped input data, select scenario waveform, and then click Mark for Simulation.

  10. Click Save.

    Save the scenario under a name such as ex_slrt_inport_waveform_scenario.mldatx.

  11. Close the Root Inport Mapper. In the In1 block parameters dialog box, click OK.

  12. To display the output of the Mux block with the Simulation Data Inspector, right-click the output signal and select Log Selected Signals.

You can now save, build, download, and execute the real-time application. Display the output with the Simulation Data Inspector.

Update Inport to Use Sawtooth Wave

You can update the inport data to use a different data file without rebuilding the real-time application. The ex_slrt_inport_osc.mldatx file must be in the working folder.

  1. Load ex_slrt_inport_sawtooth.mat, and then assign sawtooth to the temporary variable that you used with Root Inport Mapper.

    load(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', ...
    waveform = sawtooth;
  2. Create an application object.

    app_object = SimulinkRealTime.Application('ex_slrt_inport_osc');
  3. Update the application object.

  4. Load the updated object to the target computer and execute it.

    tg = slrt;
    load(tg, 'ex_slrt_inport_osc');
  5. Display the output with the Simulation Data Inspector.

Related Topics