- In the relevant "Subsystem Reference" block, create a mask with a dialog parameter with the name "<variable>" by following the steps in the documentation page Create a Simple Mask.
- Right click on the "Subsystem Reference" block and select "Properties" in the drop-down menu.
- Navigate to the "Callbacks" tab and select the "StartFcn" option in the callback list.
- In the code area, enter the following code:Where <dimension> is an integer with a value of 1 greater than the dimension requested of the input signal. The first element of "CompiledPortDimensions" is the always the size of the resulting array.portHandles = get_param(gcb, ‘PortHandles’);portDims = get_param(portHandles.Inport, ‘CompiledPortDimensions’);set_param(gcb, ‘<variable>’, num2str(portDims(<dimension>)));
How can I use a subsystem reference mask to find the dimensions of an input signal in Simulink R2024a?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2025 年 9 月 16 日
回答済み: MathWorks Support Team
2025 年 10 月 24 日 13:27
In my Simulink R2024a model, I have a "Subsystem Reference" block that accepts an input signal. I would like to use the mask parameters on this block to find the dimensions of the input signal, instead of using extra blocks such as a "Width" block. How can I achieve this workflow?
採用された回答
MathWorks Support Team
2025 年 9 月 16 日
As of MATLAB R2024a, this workflow is not supported. To find the dimensions of a port signal, you may use the "CompiledPortDimensions" block parameter. However, since masks are evaluated during model compilation, this block parameter will not be available upon calling "get_param". Please refer to the documentation page Determine Signal Dimensions for more information about "CompiledPortDimensions".
As a workaround, you can use the "StartFcn" block callback instead of a mask, which runs after a model is compiled and before it starts running. To do so, please follow these steps:
For more information about the "StartFcn" callback and block parameters, please refer to the documentation pages Block Callbacks and Set Block Parameter Values, respectively.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Subsystems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!