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

7 次查看(过去 30 天)
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 ?

回答(1 个)

Shivansh
Shivansh 2024-5-26
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!

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by