How to convert Block parameter to input port?

조회 수: 3 (최근 30일)
Rahul Bhadani
Rahul Bhadani 2019년 11월 10일
답변: Jesús Zambrano 2019년 11월 16일
Hi, I have a specific question about Simulink. Is it possible to convert a mask parameter to an input port?
For example, take sine block in Simulink (See the picture).
There is a parameter/field in the block parameters called Amplitude. Is it possible to make this as an input port of that block instead of specifying as a parameter?
Screenshot from 2019-11-09 14-46-57.png

답변 (2개)

Jesús Zambrano
Jesús Zambrano 2019년 11월 11일
Hi Rahul,
One possible simple solution would be to keep the Sine wave amplitud equal to 1, and then add the following to the block:
amplitud.png
and then you create your [t,u] vector with the changes you want for the sine wave amplitud.
Hope this can help to solve your question.
Best,
Jesús
  댓글 수: 1
Rahul Bhadani
Rahul Bhadani 2019년 11월 13일
Hi Jesus,
My question is more of general rather than specifically sine block. If you look at the Vehicle Body 3DOF block provided in the simulink, prior to 2019a, Initial yaw angle, initial lateral position and initial longitudinal position were only block parameters, but from 2019a onwards they are now input signals. By giving this example, all I am trying to say that people at Mathworks were able to convert block parameters of a certain block to input signals. I want it for every other block in the simulink.
Let me know if you understand the question and your thoughts on it.

댓글을 달려면 로그인하십시오.


Jesús Zambrano
Jesús Zambrano 2019년 11월 16일
Hi Rahul,
In general you could try to work with a MATLAB funcion block in the following way:
mymodel.png
where the MATLAB function has the following code:
function fcn(u)
coder.extrinsic('assignin')
coder.extrinsic('set_param')
assignin('base','MyGain',u)
set_param(bdroot,'SimulationCommand','update')
In summary,an input signal goes to a MATLAB function block, which saves the value in the base workspace with name MyGain, and that parameter is then used in the Gain block.
Hope this workflow can help you.
Best,
Jesús

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by