MATLAB source code contains a functions declaration. The m-file is a text file containing a list of commands written in MATLAB or Octave syntax. You can define functions and scripts in the m-file.
You can move the mathematical expressions from MATLAB source code into the model. Use the m-file to transfer functions to a Constraint Block, Constraint Property, or Call Behavior Action.
Creation of elements from MATLAB source code is supported in the following diagrams:
To wrap the mathematical expressions from MATLAB source code into the model, use one of the following methods:
|
To set constraints and parameters for a Constraint Block using m-file
The following figure illustrates the function declaration in m-file. It is for least-square fitting to find the slope (m) and the y-intercept (b) of a straight-line equation from two given input parameters x and y. The constraint expression is: [m, b] = linefit(x, y). The constraint parameters are x, y, m, and b. After the function transfer into the element, its type, property, and parameter are set automatically and are displayed on the element shape. |