How to use input signals as variables in Simulink blocks?

155 ビュー (過去 30 日間)
Chris Mounce
Chris Mounce 2018 年 5 月 22 日
回答済み: Rishabh Rathore 2018 年 5 月 24 日
How can I use an input signal as a variable for one of the block parameters of a block, such as the Slope or Initial Value for a Ramp block? The ramp is just an example, as I would like to apply this to other blocks as well. Thanks!

回答 (2 件)

Rishabh Rathore
Rishabh Rathore 2018 年 5 月 24 日
oh, you want use input signals as values for parameter? I'm afraid that's not possible. Signals and parameters are two different things altogether. It is possible to use signal to specify number of input ports for blocks like multiport switch, but in general you cannot use signals as values for parameters.

Rishabh Rathore
Rishabh Rathore 2018 年 5 月 23 日
Here's what I understand from you question, you want to use variables as input/parameters not constants.
So the way you can do this is define the parameter in workspace of matlab and use that variable instead of the constant values as parameter.
Steps required:-
  1. Define the variable for parameter in workspace
  2. double click the block to open parameter dialogue box
  3. use the variable name defined in the workspace for the relevant parameter.
Note:- Make sure that the variable get initialized/assigned before it's been used.
  1 件のコメント
Chris Mounce
Chris Mounce 2018 年 5 月 23 日
While I appreciate the answer, I know that I can set "X=5" and then use X in the parameter. I'm looking more as to how to use an input signal from an input port(In1) as a parameter in the block.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by