Be the first to rate this file! 8 Downloads (last 30 days) File Size: 192 KB File ID: #18075

Vectorizable Embedded MATLAB Function

by

 

19 Dec 2007 (Updated )

This set of Simulink models demonstrates how to create a reusable Embedded MATLAB function for scala

| Watch this File

File Information
Description

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/

Required Products Simulink
MATLAB release MATLAB 7.5 (R2007b)
Other requirements The mex32 files included with this demo were built using the LCC compiler on a Windows XP platform. The models can be used on any supported platform with any supported compiler, but will require recompilation of the mex32 files.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us