Hi Mariusz,
I understand that you are running into an error while working with a PID Controller block inside a ‘For Each’ subsystem.
Please note that the possible cause behind this error is the 'eval' function which is called in the “icon drawing” commands of the PID Controller block. This function call is creating an error because of the use of partitioned mask parameters for the PID Controller block.
In this case, as a workaround, you can modify the “icon drawing” commands of the block's mask. To do so, please follow the steps below:
- Note that the PID Controller block contains a locked link to its library. The first step is to disable this link in order to modify the block's mask. Select the PID Controller block in your model and type
set_param(gcb, 'LinkStatus', 'inactive')
in the MATLAB Command Window. This will deactivate the block’s link to its library.
- The second step is to modify the icon drawing commands of the block's mask. Right click the PID Controller block and select 'Mask' -> 'Edit Mask'. Navigate to the 'Icon' tab inside the Mask Editor. Now comment out the call to the 'eval' function on line 2. To retain the icon on the block you can add a
statement on line 3.
- Save the mask by clicking on the 'Save Mask' button on the top left. Please note that it may take a few seconds for the mask to be saved successfully.
On running the model now, you should not encounter any error.
Additionally, if you wish to view the response curves for various values of the parameter 'P' in one plot, you should move the ‘Scope’ block out of the Subsystem, and replace the ‘Scope’ block with the ‘Outport’ block inside the Subsystem.
You should obtain a ‘Scope’ plot similar to the one attached below after making the aforementioned changes to your model file:
Hope this helps!