使用matlab的ode45函数时,颂歌之间是否存在内在的相互作用?

时间:2015-05-09 14:19:45

标签: matlab ode interaction

我正在尝试使用Matlab的ODE45函数模拟两个块中的群体之间的相互作用(扩散)。 每个区块的人口由同一组ODE管理,但具有不同的初始条件。

然而,我发现即使两个区块之间没有相互作用项(因此它们应该是独立的),初始条件的差异似乎仍然影响其中的人口。这意味着,当一起计算时,块中的群体与单独计算时的群体不同。对此有解释吗?

我用一个非常简单的模型来尝试这个概念证明:

函数调用:

$"..."

仅在一个块中的函数建模群:

[t1,y1] = ode45(@equations, [1:20], [100; 50]); % block 1
[t2,y2] = ode45(@equations, [1:20], [100; 100]); % block 2
[t3,y3] = ode45(@equations2, [1:20], [100;50;100;100]); % (block 1, block 2)

功能建模两个块,但没有交互:

function [dydt] = equations(t,y)

dydt = [(y(1) + 5*y(2)); ... %m
        (-y(2) - 2*y(1)); ... %n
       ];
return

分别计算两个区块时的结果:

function [dydt] = equations2(t,y)

dydt = [(y(1) + 5*y(2)); ... %m, block 1
       (-y(2) - 2*y(1)); ... %n, block 1

       (y(3) + 5*y(4)); ... %m, block 2
       (-y(4) - 2*y(3)); ... %n, block 2
       ];
return

两个块一起计算的结果:

 100                50                  100                 100
-82.5651126482403   -61.2399111160678   -70.8298703784238   -113.079426303262
63.5149326478799    71.2611808361777    40.2624466444427    123.919353592460
-43.1859556122909   -79.8393860152817   -8.90683490348150   -132.277927048621
21.9743397563556    86.8220697463693    -22.6303780909040   137.973908367664
-0.354918519359671  -92.0989416214417   53.7225657700143    -140.919984325956
-21.2629138588043   95.5352361959004    -83.7315196717762   141.098469411677
42.4644938860107    -97.0482785784471   112.050303306456    -138.445708319198
-62.8212058809813   96.6327114704933    -138.138533695681   133.012881410501
81.9247177241794    -94.3111553111835   161.481224015549    -124.963465578347
-99.3812030807478   90.1082810663461    -181.603255611880   114.429891038409
114.845927928453    -84.0902243542573   198.088587603452    -101.593579579227
-128.038489201868   76.4154884940680    -210.635351405432   86.7397437298800
138.675067137440    -67.2257825991193   219.018298709806    -70.1774427449607
-146.535410253369   56.6883955999672    -223.021403427644   52.2241854879404
151.485921591776    -45.0236010893207   222.530966569364    -33.2118012943491
-153.442292768067   32.4726456791801    -217.644899082991   13.5504349990489
152.321501615162    -19.2743265017041   208.457113276080    6.36250787673260
-148.144949801383   5.68381588482233    -195.066043293572   -26.1560882959426
141.024940766196    8.01698112966525    177.792461039602    45.4369626814643

1 个答案:

答案 0 :(得分:0)

结果有多少不同? Ode45是一种具有步长控制的方法。用于控制步长的局部误差的计算对于联合系统肯定是不同的(不一定更好或更差)。但是,值的结果差异应保持在方法中使用的相对和绝对容差范围内,默认情况下为1e-6。使用较小的公差应该"解耦"两个系统达到相应的程度。

PS:最后显示的数字有变化,正确的结果应为

 1 [ 100.           50.          100.          100.        ]
 2 [ -82.53524872  -61.2596255   -70.77524805 -113.11125047]
 3 [  63.41855387   71.29313918   40.13392902  123.95857849]
 4 [ -43.03253624  -79.8997202    -8.68932914 -132.32487471]
 5 [  21.7852221    86.90710777  -22.92918773  138.04268767]
 6 [  -0.101876596 -92.1750490    54.0887768  -140.997575  ]
 7 [ -21.58350797   95.59810598  -84.16577854  141.1303955 ]
 8 [  42.83689848  -97.10776622  112.55820169 -138.43848988]
 9 [ -63.23290817   96.67381387 -138.69777167  132.97573693]
10 [  82.36331078  -94.30493447  162.06130481 -124.85147371]
11 [ -99.84521116   90.04854117 -182.18117983  114.2283074 ]
12 [ 115.32870896  -83.9898257   198.6546973  -101.31886073]
13 [-128.50390187   76.2500533  -211.15213965   86.38151638]
14 [ 139.1070883   -66.98413557  219.42337049  -69.71524539]
15 [-146.92604542   56.37752991 -223.30284108   51.65362329]
16 [ 151.80427675  -44.6425276   222.71290379  -32.55815357]
17 [-153.64414443   32.0140048  -217.66536621   12.81103218]
18 [ 152.40882353  -18.74472148  208.26125485    7.1925021 ]
19 [-148.12303898    5.10026242 -194.68879305  -27.05207841]
20 [ 140.87257081    8.64627842  177.21963374   46.37020718]

在第一行中,你的两个游戏都已经无法接受了。