Documentation

getInputString

Create comma-separated list of variables to map

Syntax

  • externalInputString = getInputString(inputmap,'base')
    example
  • externalInputString = getInputString(inputmap,filename)
    example
  • externalInputString = getInputString(inputmap)
    example

Description

example

externalInputString = getInputString(inputmap,'base') creates an input character vector using the supplied mapping inputmap and the variables loaded in the base workspace ('base').

This function generates a comma-separated list of variables (input character vector) to be mapped. You can then use this list:

  • As input to the sim command. Load the variables in the base workspace first.

  • As input for the Configuration Parameters > Data Import/Export > Input parameter. Copy the contents of the input character vector into the text field.

This function is most useful if you have created a custom mapping.

example

externalInputString = getInputString(inputmap,filename) creates an input character vector using the supplied mapping inputmap and the variables defined in filename.

example

externalInputString = getInputString(inputmap) creates an input character vector using the signals from the most recently created mapping.

Examples

collapse all

Create an input character vector from the base workspace and simulate a model.

Open the model

slexAutotransRootInportsExample;

Create signal variables in the base workspace

Throttle = timeseries(ones(10,1)*10);
Brake    = timeseries(zeros(10,1));

Create a mapping (inputMap) for the model.

inputMap = getRootInportMap('model',...
'slexAutotransRootInportsExample',...
'signalName',{'Throttle','Brake'},...
'blockName',{'Throttle','Brake'});

Call getInputString with inputMap and 'base' as inputs.

externalInputString = getInputString(inputMap,'base')
externalInputString =

Throttle,Brake

Simulate the model with the input character vector.

sim('slexAutotransRootInportsExample','ExternalInput',...
externalInputString);

Create an external input character vector from variables in a MAT-file named input.mat.

In a writable folder, create a MAT-file with input variables.

Throttle = timeseries(ones(10,1)*10);
Brake    = timeseries(zeros(10,1));
save('input.mat','Throttle','Brake');

Open the model.

slexAutotransRootInportsExample;

Create map object.

inputMap = getRootInportMap('model',...
'slexAutotransRootInportsExample',...
'signalName',{'Throttle','Brake'},...
'blockName',{'Throttle','Brake'});

Get the resulting input character vector.

externalInputString = getInputString(inputMap,'input.mat')
externalInputString =

Throttle,Brake

Load variables from the base workspace for the simulation.

load('input.mat');

Simulate the model.

sim('slexAutotransRootInportsExample','ExternalInput',...
externalInputString);

Create an input character vector from only an input map vector and simulate the model.

Open the model.

slexAutotransRootInportsExample;

Create signal variables in the base workspace

Throttle = timeseries(ones(10,1)*10);
Brake    = timeseries(zeros(10,1));

Create a mapping vector for the model.

inputMap = getSlRootInportMap('model', 'slexAutotransRootInportsExample',...
'MappingMode','BlockName',...
'signalName',{'Throttle', 'Brake'},...
'signalValue',{Throttle, Brake});  

Get the resulting input character vector.

externalInputString = getInputString(inputMap)

Simulate the model with the input character vector.

sim('slexAutotransRootInportsExample','ExternalInput',...
externalInputString);

Alternatively, if you want to input the list of variables through the Configuration Parameters dialog, copy the contents of externalInputString (Throttle,Brake) into the Data Import/Export > Input parameter. Apply the changes, and then simulate the model.

Input Arguments

collapse all

Map object, as returned from the getRootInportMap or getSlRootInportMap functions.

Input variables, contained in a MAT-file. The file contains variables to map.

Example: 'data.mat'

Data Types: char

Output Arguments

collapse all

External input, returned as a comma-separated character vector. The character vector contains root inport information that you can specify to the sim command or the Configuration Parameters > Data Import/Export > Input parameter.

Introduced in R2013a

Was this topic helpful?