简单的 MATLAB/Octave 仿真
对于任何在该领域有一定经验的人来说,这应该是一个非常简单的问题,但我对此仍然很陌生。
我有以下系统(或这是分辨率更高的图像):
替代文本 http://img199.imageshack.us/img199/2140/equation1.png< /a>
给定以下输入:
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
我需要绘制系统输出y。
我用以下函数描述系统:
function xprime = func(t, x)
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
xprime = [
x(2);
x(3);
0.45*u - 4*x(3)^2 - x(2)*x(1) - 4*x(2) - 2*x(1);
x(5);
sin(t) - 3*x(5)*x(1);
];
并用ode23
进行模拟,如下所示:
[tout, xout] = ode23(@func, [0 15], [1.5; 3; -0.5; 0; -1])
模拟后,xout
将有五列。我的问题是:我如何知道哪一个是 y 系统的输出?
编辑: 好的,简单来说,我想绘制这样的解决方案:
a = 1 % what goes here? 1, 2, 3, 4 or 5?
plot(tout, xout(:,a))
This should be a very simple question for anyone who has some experience in this area, but I'm still new to this.
I have the following system (or here is an image with better resolution):
alt text http://img199.imageshack.us/img199/2140/equation1.png
Given the following input:
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
I need to plot the output of system y.
I am describing the system with the following function:
function xprime = func(t, x)
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
xprime = [
x(2);
x(3);
0.45*u - 4*x(3)^2 - x(2)*x(1) - 4*x(2) - 2*x(1);
x(5);
sin(t) - 3*x(5)*x(1);
];
and simulating with ode23
, like this:
[tout, xout] = ode23(@func, [0 15], [1.5; 3; -0.5; 0; -1])
After the simulation, xout
will have five columns. My question is: how do I know which one is the output of the y system?
EDIT: Ok, so to put it simple, I'd like to plot the solution like this:
a = 1 % what goes here? 1, 2, 3, 4 or 5?
plot(tout, xout(:,a))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,对应于 y 的那个看起来是 x(1)。
如果将代码与方程进行比较,您可以看到 x(1) 出现在代码中 y 出现在方程中的每个位置。这是我最好的猜测。
The one that corresponds to y, which appears to be x(1), of course.
If you compare your code to the equations, you can see that x(1) appears in the code every place that y appears in the equations. That would be my best guess.
[T,Y,TE,YE,IE] = ode23(odefun,tspan,y0,options)
下表列出了求解器的输出参数。
伊斯滕菲塞塞!
[T,Y,TE,YE,IE] = ode23(odefun,tspan,y0,options)
The following table lists the output arguments for the solvers.
Isten fizesse!