家伙在simu万博1manbetxlink上

万博1manbetx基于模型的设计

欢迎!

Welcome to the MATLAB Central Simulink blog! The purpose of this blog is twofold: First, I want to share Simulink tips and tricks that I've learned over the years. At the same time, I hope to learn from you about your experiences with Simulink. Where is it good? How can we improve it?

I've been using Simulink for 9 years, first as a member of our technical support team, and then as a trainer. I still remember when I first learned about the power of Simulink as a newly hired support engineer back in 1998. During a training class I saw differential equations drawn on a whiteboard and then simulated with a few clicks of the mouse. I got excited by how clearly it all worked. Simulink provided me with a framework for thinking about systems and the relationships between their basic components.

当然,Simulink万博1manbetx不仅仅是解决微分方程的简单工具。它具有丰富的深度和深度,可以使我有很多材料可以借鉴。您期望在这里阅读什么样的话题?我们将讨论Simulink在控件,信号处理和通信系统设计中的应用。万博1manbetx在您的帮助下,我们将讨论如何在我什至不知道的领域使用Simulink。万博1manbetx一般而言,我们将讨论基于模型的设计,我们将了解Simulink的某些内部机械。万博1manbetx我期待所有这些有关的帖子:

  • solvers
  • sample times
  • modeling
  • hacks
  • blocks
  • 模型参考
  • libraries
  • 掩蔽
  • 自定义代码

一个示例:批处理模拟

让我从一个有关运行模拟的具体示例开始。万博1manbetxSimulink模型是使用框图构建的,一旦创建了大多数人,大多数人都会通过单击工具栏上的运行按钮来运行它们。

If you have to run a sweep of parameters you might change the parameter and then click run, change it again and click run. But if you have to run hundreds or thousands of simulations while modifying a parameter you will want to write a script for batch simulation. You can run simulations directly from MATLAB with thesimcommand like so.

>> [t,x,y] = sim(sys);

This returns the root level outputs (y) and the internal states of the model (x) at each recorded time step (t). A batch script might look like this:

open_system('vdp_mu') muSweep = .5:.1:1.5;fori = 1:length(muSweep) mu = muSweep(i); [t,x,y] = sim('vdp_mu');plot(t,y); hold;end标题('VDP States for mu=.5 to 1.5')xlabel('Time');传奇('x1','x2')

If you are already familiar with thesim命令,然后您可能知道,有时您只对模型的输出(y)感兴趣,而不是状态(x)。对于大型模型或长期模拟,这些状态可变输出可能是浪费宝贵的内存。使用simset您可以为simcommand to specify that you only want time (t) and outputs (y). The state variable returned fromsim将是空的。

[t,x,y] = sim('vdp_mu',[],simset('OutputVariables','ty')); whostxy
名称大小字节类属性t 206x1 1648 double x 0x0 0 double y 206x2 3296 double

You can learn more aboutsimsimsetin the Simulink documentation

你怎么看?

那是您的第一个Simulink提示。万博1manbetx现在轮到你了。您喜欢Simulink吗?万博1manbetx您想在以后的帖子中谈论什么?请在下面发表评论。我从Dougthat t-shirts get comments on your blog, so I'll be randomly selecting five commenters on this post to receive a MathWorks t-shirt!




Published with MATLAB® 7.5

|
  • print
  • send email

注释

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