![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176470/image.png)
How to convert block parameters into input ports in Simulink
6 次查看(过去 30 天)
显示 更早的评论
Hi, I would like to know if there is any way to convert block parameters into input ports? For example I have a Multi-Port Switch and I would like to enter the "Number of data ports" as an input:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164323/image.jpeg)
I know we can control this parameter through Matlab workspace, but I'm wondering if there is any way to control through an input.
Thanks, --Kash
0 个评论
回答(2 个)
David Ding
2017-5-25
Hi Khashayar,
It depends on the blocks you are working with. For example, in your case of a Multiport Switch, this is possible. Simply connect the first inport with a constant block. The value of the constant block will determine the number of inputs for the Multiport Switch. The value of the Constant block can be extracted as follows:
str2double(get_param('testModel/Constant', 'Value'))
I am attaching the screenshot "testModel.png" for your reference.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176470/image.png)
Thanks,
David
1 个评论
Arshad Shaik
2022-2-17
David,
Is there a way to convert block parameters - Integrator High limit and Low limit - into the input signals to the Integrator block?
Appreciate your response.
Thank you,
Arshad S.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!