simulink教程(自动控制原理)

1.启动simulink
命令行输入simulink或者
在这里插入图片描述
会弹出
在这里插入图片描述

2,点击blank model,出现新窗口

在这里插入图片描述
新建或者打开模型文件
在这里插入图片描述
There are two major classes of items in Simulink: blocks and lines. Blocks are used to generate, modify, combine, output, and display signals. Lines are used to transfer signals from one block to another.

There are several general classes of blocks within the Simulink library:

Sources: used to generate various signals
Sinks: used to output or display signals
Continuous: continuous-time system elements (transfer functions, state-space models, PID controllers, etc.)
Discrete: linear, discrete-time system elements (discrete transfer functions, discrete state-space models, etc.)
Math Operations: contains many common math operations (gain, sum, product, absolute value, etc.)
Ports & Subsystems: contains useful blocks to build a system

在这里插入图片描述
在这里插入图片描述

RUN

添加block,修改transfer function
在这里插入图片描述

在这里插入图片描述
run
在这里插入图片描述

继续修改transfer function
在这里插入图片描述
在这里插入图片描述
Since the new transfer function has a very fast response, it compressed into a very narrow part of the scope window. This is not really a problem with the scope, but with the simulation itself. Simulink simulated the system for a full ten seconds even though the system had reached steady state shortly after one second.

To correct this, you need to change the parameters of the simulation itself. In the model window, select Model Configuration Parameters from the Simulation menu. You will see the following dialog box.

在这里插入图片描述
There are many simulation parameter options; we will only be concerned with the start and stop times, which tell Simulink over what time period to perform the simulation. Change Start time from 0.0 to 0.8 (since the step doesn’t occur until t = 1.0). Change Stop time from 10.0 to 2.0, which should be only shortly after the system settles. Close the dialog box and rerun the simulation. Now, the scope window should provide a much better display of the step response as shown below.
在这里插入图片描述
在这里插入图片描述

Building Systems

First, you will gather all of the necessary blocks from the block libraries. Then you will modify the blocks so they correspond to the blocks in the desired model. Finally, you will connect the blocks with lines to form the complete system. After this, you will simulate the complete system to verify that it works.

Gathering Blocks

Follow the steps below to collect the necessary blocks:

Create a new model (New from the File menu or hit Ctrl-N). You will get a blank model window.
Click on the Tools tab and then select Library Browser.
Then click on the Sources listing in the Simulink library browser.

在这里插入图片描述
This will bring up the Sources block library. Sources are used to generate signals.

Drag the Step block from the Sources window into the left side of your model window.
在这里插入图片描述

Click on the Math Operations listing in the main Simulink window.
From this library, drag a Sum and Gain block into the model window and place them to the right of the Step block in that order.
Click on the Continuous listing in the main Simulink window.
First, from this library, drag a PID Controller block into the model window and place it to the right of the Gain block.
From the same library, drag a Transfer Function block into the model window and place it to the right of the PID Controller block.

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

Click on the Sinks listing in the main Simulink window.
Drag the Scope block into the right side of the model window.

在这里插入图片描述
Modify Blocks

Double-click on the Sum block. Since you will want the second input to be subtracted, enter ± into the list of signs field. Close the dialog box.
Double-click the Gain block. Change the gain to 2.5 and close the dialog box.
Double-click the PID Controller block and change the Proportional gain to 1 and the Integral gain to 2. Close the dialog box.
Double-click the Transfer Function block. Leave the numerator [1], but change the denominator to [1 2 4]. Close the dialog box. The model should appear as:
Change the name of the PID Controller block to PI Controller by double-clicking on the word PID Controller.
Similarly, change the name of the Transfer Function block to Plant. Now, all the blocks are entered properly. Your model should appear as:
在这里插入图片描述

Drag the mouse from the output terminal of the Step block to the positive input of the Sum input. Another option is to click on the Step block and then Ctrl-Click on the Sum block to connect the two togther. You should see the following.

Drag a line off the negative portion of the Sum block straight down and release the mouse so the line is incomplete. From the endpoint of this line, click and drag to the line between the Plant and the Scope. The model should now appear as follows.
在这里插入图片描述
以上照做后可能会报错
在这里插入图片描述
解决方法就是
在这里插入图片描述
在这里插入图片描述
解决

在这里插入图片描述

参数可以用代数代替
In some cases, parameters, such as gain, may be calculated in MATLAB to be used in a Simulink model. If this is the case, it is not necessary to enter the result of the MATLAB calculation directly into Simulink. For example, suppose we calculated the gain in MATLAB in the variable K. Emulate this by entering the following command at the MATLAB command prompt.

在这里插入图片描述
在这里插入图片描述
也可以run

  • 11
    点赞
  • 92
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值