If 和多语句

If and Multiple Statement

我是 Simulink 的新手。

我想实现以下目标:

if(U1 > U2)
{
   E = U1 + U2
   D = U1 * A
}
else if(U1 < U2)
{
   E = U1 - U2
   D = U1 * B
}
else
{
   E = U1
   D = U2 * U2
}

请问如何在 Simulink 中表示上述内容

您可以通过多种方式实现这一点。

一个是使用 If subsystem. On the left of the image below is the high level of the implementation. On the right are the contents of the If, ElseIf and Else subsystems. You probably also want to look at the doc for the Merge 块来查看它如何 选择 通过哪个信号作为 DE.

另一种方法是使用 MATLAB Function 块,