Vectorizable Embedded MATLAB Function

版本 1.0.0.1 (192.5 KB) 作者: Bill Potter
This set of Simulink models demonstrates how to create a reusable Embedded MATLAB function for scala
1.5K 次下载
更新时间 2016/9/1

查看许可证

The three Simulink models provided demonstrate how to develop a reusable Embedded MATLAB function that can be used on scalars and vectors. The Embedded MATLAB function, a simple quadratic equation, is implemented in the model my_eml_func.mdl. This model is referenced as a Model Reference in the library my_lib.mdl. The library contains a configurable subsystem that can be set to either a scalar or vector choice. The scalar choice contains just the reference model for the Embedded MATLAB function and the vector choice contains the same reference model plus a for iterator, vector selector blocks and a vector assignment block. The latter subsystem allows the Embedded MATLAB function to operate in a for loop that addapts to the size of the input signals. A third model, eml_mr_inherited_dim.mdl, includes three instances of the library block to demostrate how the single Embedded MATLAB function can be used for a scalar input, a vector input of width 3 and a vector input of width 5.
This example does have two limitations. This first limitation is that all inputs to the function must have the same vector width. The second limitation is that the Embedded MATLAB function cannot contain any persistent variables.

This technique allows a reusable Embedded MATLAB function to be built and tested once, then the function can be reused many times in other models on any size input vector.

For more information about the Embedded MATLAB subset, please visit the MathWorks web-site:
http://www.mathworks.com/products/featured/embeddedmatlab/

引用格式

Bill Potter (2024). Vectorizable Embedded MATLAB Function (https://www.mathworks.com/matlabcentral/fileexchange/18075-vectorizable-embedded-matlab-function), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Prepare Model Inputs and Outputs 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.1

Updated license

1.0.0.0

Corrected summary and added product link.