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)




System; object to be exported



string; main S-Function block file name



string; Simulink® block diagram file name



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



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.



Parameter values




Differential equation.





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



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