Is there some way to execute a MATLAB function only once at the start
of a Simulink simulation and read in a 2D matrix generated by that
MATLAB function into a Lookup table block? The 2D matrix is not an
input signal or function of the simulation time.
------------------
The detailed explanation of the problem:
I'm currently moving a large MATLAB simulation over to simulink.
One particular function in the simulation is only called at the
beginning of the simulation and outputs a 2D matrix of real elements.
These elements are accessed, but not changed at various times in the
simulation. A sizeable portion of this function generating the
script resides in a for loop which typically loops 500 times. Each
loop outputs a single 3X1 vector. The 3x1 vector output of one loop
is entirely dependent on the previous 3X1 vector. The total matrix
output will be 3X500.
I'm trying to determine the most efficient way to put this function
into Simulink. I've considered the following:
(1) Direct Block Realization - To calculate the 3X500 matrix at time
0 would required a huge number of blocks.
(2) M File S-Function (level 1)
(3) Embedded Matlab Function
For (2) and (3), I am concerned about longer simulation times. I
also want to make sure that the 3x500 matrix is only generated once.
I don't want my simulation wasting time regenerating the value at
every discrete interval.
Is there some way to execute a MATLAB function once at the start of a
Simulink simulation and read in a 2D matrix value into a Lookup table
block?
There is a way to do this directly in simulink, but in the moment I'm
not sure where to find...
But the first way has to work!
Hope this helps
Hi Steve,
Check out the doc about model callback functions:
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/creating_model41.html#56417
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/creating_model47.html#132871
HTH,
Amanda