Vectorizable Embedded MATLAB Function

This set of Simulink models demonstrates how to create a reusable Embedded MATLAB function for scala
1,5K téléchargements
Mise à jour 1 sept. 2016

Afficher la licence

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/

Citation pour cette source

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

Compatibilité avec les versions de MATLAB
Créé avec R2007b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Prepare Model Inputs and Outputs dans Help Center et MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0.1

Updated license

1.0.0.0

Corrected summary and added product link.