generate code to create a Simulink® diagram - MapleSim Connector Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim Toolboxes : MapleSim Connector : MapleSimConnector Package : Deprecated Components : MapleSimConnector/SBlock/GenerateSBlock

MapleSimConnector[SBlock][GenerateSBlock] - generate code to create a Simulink® diagram

Calling Sequence

GenerateSBlock(system, sourcename, blockname, opts)

Parameters

system

-

System; object to be exported

sourcename

-

string; main S-Function block file name

blockname

-

string; Simulink® block diagram file name

opts

-

(optional) equation(s) of the form option = value; specify options for GenerateSBlock

Description

• 

The GenerateSBlock command generates a sequence of MATLAB® commands (referred to as m-script commands) that compile the code generated by MapleSimConnector[SBlock] for the system object and create a Simulink® diagram (with the name specified by blockname that calls the compiled code (whose source file is specified by sourcename).

• 

The m-script commands are generated as a single string (with each line of code separated by the new line character "\n"). The generated m-script code string can be saved to a file (using MapleSimConnector[SaveCode]).

• 

If the target option is C, the generated script first creates a call to the mex MATLAB® command to compile the C file. This requires the mex command to be set up in MATLAB® before executing the generated code. Refer to MapleSimConnector[setup] for instructions on how to set up the mex command.

• 

The generated m-script commands, upon execution in MATLAB®, call Simulink® to create either a Model or Library diagram. The type of diagram to be created is specified by the model option (see the Options section). Simulink® must be installed and configured before you can execute the generated code.

• 

The resulting Simulink® block consists of a single Subsystem block, whose name is specified by blockname. This blockname subsystem has the same number of input and output ports as in the given system. Within the blockname subsystem, it contains five main elements: input ports; a MUX block; a S-Function block; a DEMUX block; and output ports.

– 

The name of the Input Ports (inports) are extracted from the given system object.

– 

The MUX block combines the inputs into a single signal vector to be connected to the S-Function block. The MUX block is given the name Inputs.

– 

The S-Function block has only a single input vector and a single output vector. The name of the S-Function block is given by blockname.

– 

The DEMUX block separates multiple output signals from the S-Function block. The DEMUX block is given the name Outputs.

– 

The name of the Output Ports (outports) is also extracted from the given system object.

– 

A mask is created for the Subsystem block if the parameters option is specified. The parameters must be of the type symbol. The parameter variables are available in the mask for user modification during execution time within MATLAB®. The prompt label for each parameter listed in the mask is generated from the strings specified by the labels option. If the labels option is not specified, the left-hand side of the equations defined in the parameters option is used to generate the prompt label for the mask.

Examples

withMapleSimConnector:

Parameter values

par:=m=5,b=2,k=3

par:=m=5,b=2,k=3

(1)

Differential equation.

de:=mⅆ2ⅆt2yt+bⅆⅆtyt+kyt=ut

de:=mⅆ2ⅆt2yt+bⅆⅆtyt+kyt=ut

(2)

sys1:=DynamicSystems:-DiffEquationde,inputvariable=ut,outputvariable=yt

sys1:=Diff. Equationcontinuous1 output(s); 1 input(s)inputvariable=utoutputvariable=yt

(3)

script:=SBlock:-GenerateSBlocksys1,SpringMassDamper_C1,Block,parameters=par:

See Also

MapleSimConnector, MapleSimConnector[SaveCode], MapleSimConnector[setup], Matlab, Matlab[evalM], Matlab[setup]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam