Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Memory - Output input from previous time step

Library

Discrete

Description

The Memory block outputs its input from the previous time step, applying a one integration step sample-and-hold to its input signal.

This sample model demonstrates how to display the step size used in a simulation. The Sum block subtracts the time at the previous step, generated by the Memory block, from the current time, generated by the clock.

Data Type Support

The Memory block accepts real or complex signals of any data type supported by Simulink software, including fixed-point and enumerated data types.

For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

Initial condition

The output at the initial integration step. This must be set to 0 if the input data type is user-defined. Simulink software does not allow the initial output of this block to be inf or NaN.

Inherit sample time

Check this check box to cause the sample time to be inherited from the driving block. If this option is not selected, the block's sample time depends on the type of solver used to simulate the model. If the solver is a variable-step solver, the sample time is continuous but fixed in minor time step ([0, 1]). If the solver is a fixed-step solver, this [0, 1] sample time is converted to the solver's step size after sample time propagation.

Direct feedthrough of input during linearization

Causes the block to output its input during linearization and trim. This sets the block's mode to direct feedthrough.

Enabling this check box can cause a change in the ordering of states in the model when using the functions linmod, dlinmod, or trim. To extract this new state ordering, use the following commands.

First compile the model using the following command, where model is the name of the Simulink model.

    [sizes, x0, x_str] = model([],[],[],'lincompile');

Next, terminate the compilation with the following command.

  model([],[],[],'term');

The output argument, x_str, which is a cell array of the states in the Simulink model, contains the new state ordering. When passing a vector of states as input to the linmod, dlinmod, or trim functions, the state vector must use this new state ordering.

Treat as a unit delay when linearizing with discrete sample time

Select this check box to linearize the Memory block to a unit delay when the Memory block is driven by a signal with a discrete sample time.

The State Attributes pane of the Memory block dialog box appears as follows:

State name

Use this parameter to assign a unique name to each state. The default is ' '. If left blank, no name is assigned. Consider the following when using this parameter:

  • To assign a name to a single state, enter the name between quotes, for example, 'velocity' .

  • The state names apply only to the selected block.

  • To assign names to multiple states, enter a comma-delimited list surrounded by braces. For example, {'a', 'b', 'c'} . Each name must be unique.

  • The number of states must be evenly divided by the number of state names. There can be fewer names than states, but there cannot be more names than states.

  • For example, you can specify two names in a system with four states. Simulink software will assign the first name to the first two states and the second name to the last two.

  • To assign state names with a variable that has been defined in the MATLAB workspace, enter the variable without quotes. A variable can be a string, cell, or structure.

This parameter enables State name must resolve to Simulink signal object when you click the Apply button.

State name must resolve to Simulink signal object

Select this checkbox to require that state name resolve to Simulink signal object. This check box is cleared by default.

This parameter is enabled by State name.

Selecting this check box enables Real-Time Workshop storage class.

Real-Time Workshop storage class

From the list, select state storage class.

Auto

Auto is the appropriate storage class for states that you do not need to interface to external code.

ExportedGlobal

State is stored in a global variable

ImportedExtern

model_private.h declares the state as an extern variable.

ImportedExternPointer

model_private.h declares the state as an extern pointer.

This parameter is enabled by State name.

Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Real-Time Workshop storage type qualifier.

During simulation, the block uses the following values:

See Block State Storage and Interfacing Considerations in the Real-Time Workshop Workshop documentation for more information.

Bus Support

The Memory block is a bus-capable block. The input can be a virtual or nonvirtual bus signal subject to the following restrictions:

All signals in a nonvirtual bus input to a Memory block must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus. See Using Composite Signals and Bus-Capable Blocks for more information.

Characteristics

Bus-capableYes, with restrictions as noted above

Direct Feedthrough

No, except when Direct feedthrough of input during linearization is enabled

Sample Time

Continuous, but inherited from the driving block if you select the Inherit sample time check box

Scalar Expansion

Yes, of the Initial condition parameter

Dimensionalized

Yes

Multidimensionalized

Yes

Zero Crossing

No

  


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