Using User Defined Function - MATLAB function block in Simulink

4 views (last 30 days)
Hi, I am new to matlab. I am building a model in simulink that generates an entity every 20 minutes over a simulation period of 105 units (hence 5 entities are generated). A 10 x 10 array (initialized to all zeroes) is defined using data store and a User Defined Function (MATLAB function block) is used to update the array based on attributes of the entity. The basic activity accomplished by the function is just to parse the array and update the unique id value of the entity in the array. Hence it is expected that the array would have only 5 entries at the end of the simulation due to 5 entities being created. However it is observed that 46 function calls are made and the array is updated 46 times. Upon debugging it was discovered that the function is called repeatedly during the intergeneration time between the entities. I need that the function be called only once by an entity before it is sent to sink.
Any help will be highly appreciated. Please advise if any further details are required.
Thanks.
Vishwesh

Answers (0)

Community Treasure Hunt

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

Start Hunting!