Products & Services Industries Academia Support User Community Company

Learn more about Simulink   

sim - Simulate dynamic system

Syntax

simOut = sim('model', 'ParameterName1',Value1,'ParameterName2', Value2...);
simOut = sim('model', ParameterStruct);
simOut = sim('model', ConfigSet);

Description

simOut = sim('model', 'ParameterName1',Value1,'ParameterName2', Value2...); causes Simulink software to simulate the block diagram, model, using parameter name-value pairs ParameterName1, Value1 and ParameterName2, Value2.

simOut = sim('model', ParameterStruct); causes Simulink software to simulate the block diagram, model, using the parameter values specified in the structure ParameterStruct.

simOut = sim('model', ConfigSet); causes Simulink software to simulate the block diagram, model, using the configuration settings specified in the model configuration set, ConfigSet.

Inputs

ParameterNamek

The name of a parameter to be specified for simulation.

Valuek

The value of the parameter, ParameterNamek (Value1 is the value of ParameterName1.)

ParameterStruct

A structure containing parameter settings

ConfigSet

A configuration set

Outputs

simOut

A Simulink.SimulationOutput object that contains all of the simulation outputs—logged time, states, and signals

Definitions

For all three formats of the sim command, the input(s) are parameter specifications that override those defined on the Configuration Parameters dialog box. The software restores the original configuration values at the end of simulation. For additional details about the sim command, see Using the sim Command.

Examples

Simulate the model, vdp, in Rapid Accelerator mode for an absolute tolerance of 1e-5 and save the states in xoutNew and the output in youtNew.

  1. Specify parameter name-value pairs within the sim command:

    simOut = sim('vdp','SimulationMode','rapid','AbsTol','1e-5',...
                'SaveState','on','StateSaveName','xoutNew',...
                'SaveOutput','on','OutputSaveName','youtNew');
  2. Specify parameter values in a structure, paramNameValStruct:

    paramNameValStruct.SimulationMode = 'rapid';
    paramNameValStruct.AbsTol         = '1e-5';
    paramNameValStruct.SaveState      = 'on';
    paramNameValStruct.StateSaveName  = 'xoutNew';
    paramNameValStruct.SaveOutput     = 'on';
    paramNameValStruct.OutputSaveName = 'youtNew';
    simOut = sim('vdp',paramNameValStruct);
  3. Specify a configuration set containing the parameter values:

    mdl = 'vdp';
    load_system(mdl)
    simMode = get_param(mdl, 'SimulationMode');
    set_param(mdl, 'SimulationMode', 'rapid')
    cs = getActiveConfigSet(mdl);
    mdl_cs = cs.copy;
    set_param(mdl_cs,'AbsTol','1e-5',...
             'SaveState','on','StateSaveName','xoutNew',...
             'SaveOutput','on','OutputSaveName','youtNew')
    simOut = sim(mdl, mdl_cs);
    set_param(mdl, 'SimulationMode', simMode)

Alternatives

See Also

parfor | Rapid Accelerator Simulations Using PARFOR | sldebug

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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