www.gusucode.com > simulinkcoder 案例源码程序 matlab代码 > simulinkcoder/CtrlInitValueSigsStatesDemoExample.m
%% Control Initial Value of Signals and States % When modeling dynamic systems, it is often necessary to control the initialization and % reset characteristics of signals and states. This model shows how this can be % done using the initial value property of signal objects. %% Open Example Model % Open the example model |rtwdemo_sigobj_iv|. % Copyright 2015 The MathWorks, Inc. open_system('rtwdemo_sigobj_iv') %% % In this model, the following signals and states are configured using signal objects: % % * Root input signal (|S1|) % * Discrete states initial condition (|X1|, |X2|) % * Conditionally executed subsystem output port initial output (|S2|) % * Other persistent signals (|S3|) % % The initial values of signal objects |X1| and |S2| are specified using tunable parameters % |aa1| and |aa2| respectively. %% Instructions % # Simulate the model and inspect the results in the scope display. % # Generate code by double-clicking a blue button. Inspect the generated code. % # Change the initial value of |X1| or |S2| (or the tunable parameters |aa1| or |aa2|) in the % Model Explorer and redo the simulation and code generation to inspect the results.