家伙在simu金宝applink上

金宝app基于模型的设计

如何在Simulink中绘制ODES金宝app

I remember while learning Simulink, drawing ordinary differential equations was one of the early challenges. Eventually I discovered a few steps that make it easier. First, rewrite the equations as a system of first order derivatives. Second, add integrators to your model, and label their inputs and outputs. Third, connect the terms of the equations to form the system.

示例:大规模弹簧抑制剂

The mass-spring-damper system provides a nice example to illustrate these three steps. Let’s look at the equation for this system:

弹簧质量阻尼方程

质量的位置是,速度是, 和the acceleration is

Express the system as first order derivatives

为了将其重写为一阶导数系统,我想替代for, 和for。然后我可以将我的两个状态识别为位置and velocity。方程变为

And this is rewritten at two first derivatives:


Velocity and position are the states of my system. When thinking about ODEs, states equal integrator blocks.

Add one integrator per state, label the input and output

I always make a point to write the equations as an annotation on my diagram. I refer to this as I add blocks to the canvas. Here are the two integrators for the mass-spring-damper system.

集成器块

I draw signals from the ports and label inputs as the derivative (),输出是状态变量。

Connect the terms to form the system

The first connection is easy,, so I connect the output of the velocity integrator to the input of the position integrator. When this happens, aligning the integrators in the diagram shows that you have a second order system.

集成器块,连接

要实现第二个方程式,我将收益和总和添加到图中并链接术语。

Final spring mass damper system

最后一步,初始条件

Modeling differential equations require initial conditions for the states in order to simulate. The initial states are set in the integrator blocks. Think of these as the initial value for v and x at time 0. The ODE solvers compute the derivatives at time zero using these initial conditions and then propagate the system forward in time. I used an annotation to record these initial conditions, v0 = 0, and x0 = 10.

Simulating the model for 50 seconds produces the following trace for x (blue) and v (red).

弹簧质量阻尼器范围

随着时间的流逝,我在从方程式转换为模型方面变得更加自在,而且我并不总是重写各州。我认为从根本上讲,我仍然遵循相同的过程:

  1. Re-express the system in terms of state derivatives
  2. Add integrators and label the inputs and outputs
  3. Connect up the equations
  4. Set initial conditions

现在轮到你了

Is this the same process you learned when you started using Simulink? Do you have any special tips on how to draw ODEs? Share your ideas and在这里发表评论

|
  • print
  • send email

注释

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.