Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
slref.pdf
Скачиваний:
39
Добавлен:
26.03.2015
Размер:
16.01 Mб
Скачать

Data Type

Data Type

enumeration

fixdt

fixptbestexp

fixptbestprec

fixpt_evenspace_cleanup

fixpt_interp1 fixpt_look1_func_approx

fixpt_look1_func_plot

fixpt_set_all

float

fxptdlg num2fixpt

sfix

Display or obtain enumerated type constituent values and names

Create Simulink.NumericType object describing fixed-point or floating-point data type

Exponent that gives best precision for fixed-point representation of value

Determine maximum precision available for fixed-point representation of value

Modify breakpoints of lookup table to have even spacing

Implement 1-D lookup table

Optimize fixed-point approximation of nonlinear function by interpolating lookup table data points

Plot fixed-point approximation function for lookup table

Set property for each fixed-point block in subsystem

Create MATLAB structure describing floating-point data type

Start Fixed-Point Tool

Convert number to nearest value representable by specified fixed-point data type

Create MATLAB structure describing signed generalized fixed-point data type

3-11

3 Function Reference

sfrac

Create MATLAB structure

 

describing signed fractional

 

data type

Simulink.defineIntEnumType

Define enumerated data type

sint

Create MATLAB structure

 

describing signed integer data

 

type

tunablevars2parameterobjects

Create Simulink parameter objects

 

from tunable parameters

ufix

Create MATLAB structure

 

describing unsigned generalized

 

fixed-point data type

ufrac

Create MATLAB structure

 

describing unsigned fractional

 

data type

uint

Create MATLAB structure

 

describing unsigned integer

 

data type

3-12

4

Functions — Alphabetical

List

add_block

Purpose

Syntax

Description

Add block to model

add_block('src', 'dest')

block = add_block('src', 'dest') add_block('src', 'dest', 'param1', value1, ...) add_block('src', 'dest', 'MakeNameUnique', 'on')

add_block('src_inport', 'dest_inport', 'CopyOption', 'duplicate')

add_block('src', 'dest') copies the block with the full path name that you specify with 'src' to a new block with a full path name that you specify with 'dest'. The block parameters of the new block are identical to those of the original. If the 'src' block is a Subsystem block, then add_block copies all the blocks in the subsystem.

block = add_block('src', 'dest') returns the handle of the newly created block.

add_block('src', 'dest', 'param1', value1, ...) creates a copy of the 'src' block, with the named parameters having the specified values. Additional arguments must occur in parameter/value pairs.

add_block('src', 'dest', 'MakeNameUnique', 'on') creates a unique name for the new block, based on the name of the 'dest' block. The add_block function creates a unique name only if the 'dest' block name exists in the model into which you add the new block. By default, MakeNameUnique is off.

add_block('src_inport', 'dest_inport', 'CopyOption', 'duplicate') applies only to Inport blocks. It creates a copy with the same port number as the 'src_inport' block.

Before you add a block from a source model, open the source model. For example, use load_system (model opens invisibly) or open_system (model opens visibly). Also open the destination model if it is different from the source model.

Calling add_block triggers the CopyFnc and PreCopyFcn block callback functions.

4-2

add_block

Examples

You can use 'built-in/blocktype' as a source block path name for Simulink built-in blocks, where blocktype is the built-in block type (that is, the value of its BlockType parameter (see “Common Block Parameters” on page 8-96). However, using 'built-in/blocktype' causes some default parameter values of some blocks to be different from the defaults that you get if you added those blocks interactively using Simulink.

Copy the Scope block from the Sinks subsystem of the simulink system to a block named Scope in the Controller subsystem of the f14 system.

simulink; open_system('f14');

add_block('simulink/Sinks/Scope', 'f14/Controller/Scope')

Create a subsystem named Controller2 in the f14 system. You do not have to open the Library Browser.

open_system('f14'); add_block('built-in/SubSystem', 'f14/Controller2')

Copy the built-in Gain block to a block named Speed in the f14 system and assign the Gain parameter a value of 4. You do not have to open the Library Browser.

open_system('f14');

add_block('built-in/Gain', 'F14/Speed', 'Gain', '4')

Copy the block named Mu in vdp and create a copy. Because the model already contains a Mu block, the command names the new block Mu1. Open the vdp model, which is both the source and destination model, and get the handle of the added block.

4-3

add_block

open_system('vdp');

block = add_block('vdp/Mu', 'vdp/Mu', 'MakeNameUnique', 'on')

See Also

delete_block | replace_block | set_param

Tutorials

“Create Annotations Programmatically”

How To

“Add Blocks to a Model”

 

“Create Model Callback Functions”

4-4

add_exec_event_listener

Purpose

Syntax

Description

Register listener for block method execution event

h = add_exec_event_listener(blk, event, listener);

h = add_exec_event_listener(blk, event, listener) registers a listener for a block method execution event where the listener is a MATLAB program that performs some task, such as logging runtime data for a block, when the event occurs (see “Listen for Method Execution Events”). Simulink software invokes the registered listener whenever the specified event occurs during simulation of the model.

Note Simulink software can register a listener only while a simulation is running. Invoking this function when no simulation is running results in an error message. To ensure that a listener catches all relevant events triggered by a model’s simulation, you should register the listener in the model’s StartFcn callback function (see “Model Callback Functions”).

Input blk

Arguments

Specifies the block whose method execution event the listener is intended to handle. May be one of the following:

Full pathname of a block

A block handle

A block runtime object (see “Access Block Data During Simulation”.)

event

Specifies the type of event for which the listener listens. It may be any of the following:

4-5

add_exec_event_listener

Output

Arguments

 

Event

Occurs...

 

 

'PreDerivatives'

Before a block’s Derivatives

 

 

 

method executes

 

 

'PostDerivatives'

After a block’s Derivatives

 

 

 

method executes

 

 

'PreOutputs'

Before a block’s Outputs

 

 

 

method executes.

 

 

'PostOutputs'

After a block’s Outputs method

 

 

 

executes

 

 

'PreUpdate'

Before a block’s Update

 

 

 

method executes

 

 

'PostUpdate'

After a block’s Update method

 

 

 

executes

 

listener

Specifies the listener to be registered. It may be either a string specifying a MATLAB expression, e.g., 'disp(''here'')' or a handle to a MATLAB function that accepts two arguments. The first argument is the block runtime object of the block that triggered the event. The second argument is an instance of EventData class that specifies the runtime object and the name of the event that just occurred.

add_exec_event_listener returns a handle to the listener that it registered. To stop listening for an event, use the MATLAB clear command to clear the listener handle from the workspace in which the listener was registered.

4-6

add_line

Purpose

Syntax

Description

Add line to Simulink system

h = add_line('sys','oport','iport')

h = add_line('sys','oport','iport', 'autorouting','on') h = add_line('sys', points)

The add_line command adds a line to the specified system and returns a handle to the new line. You can define the line in two ways:

By naming the block ports that are to be connected by the line

By specifying the location of the points that define the line segments

add_line('sys', 'oport', 'iport') adds a straight line to a system from the specified block output port 'oport' to the specified block input port 'iport'. 'oport' and 'iport' are strings consisting

of a block name and a port identifier in the form 'block/port'. Most block ports are identified by numbering the ports from top to bottom or from left to right, such as 'Gain/1' or 'Sum/2'.

Enable, Trigger, State, and Action ports are identified by name, such as 'subsystem_name/Enable', 'subsystem_name/Trigger', 'Integrator/State', or if_action_subsystem_name/Ifaction'.

add_line('sys','oport','iport', 'autorouting','on') works like add_line('sys','oport','iport') except that it routes the line around intervening blocks. The default value for autorouting is 'off'.

add_line(system, points) adds a segmented line to a system. Each row of the points array specifies the x and y coordinates of a point on a line segment. The origin is the top-left corner of the window. The signal flows from the point defined in the first row to the point defined in the last row. If the start of the new line is close to the output of an existing block or line, a connection is made. Likewise, if the end of the line is close to an existing input, a connection is made.

4-7

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]