フィルターのクリア

Problem passing sine wave through if statement

1 回表示 (過去 30 日間)
Matthew Tieu
Matthew Tieu 2022 年 11 月 23 日
コメント済み: Matthew Tieu 2022 年 11 月 24 日
Hi,
To see the output of an if statement over time, I wanted to pass a sine wave as input into "if block" and display it on the scope. Unfortunately, I cannot run the program since I keep receiving an error which says:
"Port 1 of 'Loops_in_Simulink/If statement' can only be connected to an action subsystem and may not be connected to more than one action subsystem".
However, as seen from the block diagram, there is only one input which is the sine wave. This simulink program is not a homework task. Could someone inform me what I am doing wrong? Thanks in advance.

採用された回答

Paul
Paul 2022 年 11 月 23 日
Hi Matthew,
The "Port 1" referenced in the error message is the first output port, not the input port. All output ports from the If block have to feed If-Action subsytems, and the outputs of those have go through a Merge block. The If and If-Action blocks implement this pseudocode:
IF cond1 Then
Action1
ElseIF cond2 Then
Action 2
Etc.
Else
ActionElse
EndIF
The model in the Question is missing the Action for the conditions.
I think the model was trying to implement functionality similar to this model:
Here, the top If-Action system outputs 1 and the bottom outputs -1. The If-Action subsystems can also accept inputs.
Of course, this model could be more easily implemented by sending the output of the Sine block into a Sign block, but I thought it would be worthwhile to illustrate how the If/If-Action works.
  1 件のコメント
Matthew Tieu
Matthew Tieu 2022 年 11 月 24 日
Thanks for the clarification about how the if statement works.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by