再从有限差分方程组的建立上说,时间time固定,即稳态问题,相当于非稳态问题方程组中的关于时间的差分式项为0。
现实 *** 作中并未做过这方面研究,以上纯属个人见解。
好难选择啊,不是一下子灭绝,就是一下子饱和。大家试试吧。clcclear
%dP/dt=RP(1-P/K)—BP^2/(A^2+B^2)
K=40000000R=106.3A=0.000001B=0.00000000000001
P=dsolve('DP=R*P*(1-P/K)-B*P^2/(A^2+B^2)','P(0)=5000')
P=simple(P)
P=subs(P)
t=0:10
P=subs(P,'t',t)
plot(t,P)
§说明: 以下代码在VS2010中实现,可以验证结果是对的.#include<stdio.h>
int main(){
double A[24][24],b[24],x[24]
int i,j
//给A,b赋初值
for(i=0i<24i++){
b[i]=i+1
for(j=0j<24j++){
if(j==i-2)A[i][j]=1
else if(j==i-1)A[i][j]=2
else if(j==i)A[i][j]=6
else if(j==i+1)A[i][j]=2
else if(j==i+2)A[i][j]=1
else A[i][j]=0
}
}
//在屏幕上输出线性方程组
for(i=0i<24i++){
for(j=0j<24j++){
printf("%2.f",A[i][j])
}printf(" %2.f\n",b[i])
}
//高斯消去(★★精髓:注意A中0的分布★★)
for(i=0i<22i++){
A[i+1][i]=A[i+1][i]/A[i][i]
A[i+1][i+1]-=A[i][i+1]*A[i+1][i]
A[i+1][i+2]-=A[i][i+2]*A[i+1][i]
b[i+1]-=b[i]*A[i+1][i]
A[i+2][i]=A[i+2][i]/A[i][i]
A[i+2][i+1]-=A[i][i+1]*A[i+2][i]
A[i+2][i+2]-=A[i][i+2]*A[i+2][i]
b[i+2]-=b[i]*A[i+2][i]
}
A[23][22]/=A[22][22]
A[23][23]-=A[23][22]*A[22][23]
b[23]-=b[22]*A[23][22]
//解上三角方程组
x[23]=b[23]/A[23][23]
x[22]=(b[22]-x[23]*A[22][23])/A[22][22]
for(i=21i>=0i--)
x[i]=(b[i]-x[i+1]*A[i][i+1]-x[i+2]*A[i][i+2])/A[i][i]
//输出解X
for(j=0j<24j++)
printf("%12.7f",x[j])
putchar('\n')
return 0
}
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0 0 0 0 0 0 1 2 6 2 1 0 21
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 6 2 1 22
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 6 2 23
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 6 24
★★★方程组的解(依次递增)★★★
0.0675341 0.1717027 0.2513901 0.3319355 0.4168487 0.5002066
0.5832332 0.6666609 0.7500171 0.8333273 0.9166876 0.9999660
1.0832707 1.1669598 1.2498363 1.3320611 1.4196698 1.5016614
1.5646997 1.6892313 1.8103466 1.6128581 1.9690418 3.0748430
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)