Clear Filters
Clear Filters

Placing a Matlab function block with a call to a Simulink function in a for each subsystem

19 views (last 30 days)
I have a Matlab function block that calls a Simulink function. I am trying to place this block into a for each subsystem and i get the following error.
The MATLAB Function cannot be placed inside a subsystem containing a "For Each" block. This might be because of one or more of the following reasons: 1. The MATLAB Function has a data with scope "Data Store Memory". 2. The MATLAB Function calls Simulink functions.
Is there a workaround to this problem ?

Answers (1)

Shivansh
Shivansh on 26 May 2024 at 12:05
Hi Rishab!
I understand that you are facing an error while putting a MATLAB function block containing data with scope "Data Store memory" inside a for each subsystem.
A possible workaround can be to remove the global variable from the MATLAB Function block and pass it as an input to the MATLAB Function block. You can use a Data Store Read outside the For Each Subsystem, use it as an input to the Subsystem, and then pass it to the MATLAB Function block as an input argument.
You can refer to the following documentation to know more about the limitations of For Each Subsystem: https://www.mathworks.com/help/simulink/ug/repeat-an-algorithm-using-a-for-each-subsystem.html#mw_76ab6d1d-3ef6-4c2e-9438-e226c070ddc0.
I hope it helps!

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!