0
當我嘗試使用dsolve
象徵性解決,它無法找到一個明確的解決方案:如何在MATLAB中求解微分方程組?
T = 5;
r = 0.005;
dsolve(
'Dp11 = p12^2/r - 4*p12 - 2',
'Dp12 = p12 - p11 - 2*p22 + (p12*p22)/r',
'Dp22 = 2*p22 - 2*p12 + p22^2/r',
'Dg1 = g2*(p12/r - 2) - 1',
'Dg2 = g2*(p22/r + 1) - g1',
'p11(T)=1',
'p12(T)=0',
'p22(T)=0',
'g1(T)=0.5',
'g2(T)=0')
syms x1 x2
x = [x1; x2];
u = -inv(R)*B'*(P*x - g)
u = -(p12*x1 - g2 + p22*x2)/r
dsolve(
'Dp11 = p12^2/r - 4*p12 - 2',
'Dp12 = p12 - p11 - 2*p22 + (p12*p22)/r',
'Dp22 = 2*p22 - 2*p12 + p22^2/r',
'Dg1 = g2*(p12/r - 2) - 1',
'Dg2 = g2*(p22/r + 1) - g1')
T = 5;
r = 0.005;
dsolve('Dp11 = p12^2/0.005 - 4*p12 - 2','Dp12 = p12 - p11 - 2*p22 + (p12*p22)/0.005','Dp22 = 2*p22 - 2*p12 + p22^2/0.005','Dg1 = g2*(p12/0.005 - 2) - 1','Dg2 = g2*(p22/0.005 + 1) - g1')
dsolve('Dp11 = p12^2/0.005 - 4*p12 - 2','Dp12 = p12 - p11 - 2*p22 + (p12*p22)/0.005','Dp22 = 2*p22 - 2*p12 + p22^2/0.005','Dg1 = g2*(p12/0.005 - 2) - 1','Dg2 = g2*(p22/0.005 + 1) - g1','p11(5)=1','p12(5)=0','p22(5)=0','g1(5)=0.5','g2(5)=0')
然後我嘗試以下方法來解決和繪圖表,但不能被ode45, failure at t = 2.39e-001 Unable to meet integration tolerances without reducing the step size below the smallest value allowed (4.44e-016) at time t
來解決 以下然後我嘗試y0 = [0 0 0 0 0]
它可以解決但它不是終端條件。我應該如何解決這個問題?
t0 = 0;
tf = 5;
y0 = [1 0 0 0.5 0];
[X, Y] = ode45(@exampleode, [t0 tf], y0);
function dy = exampleode(t, y)
r = 0.005;
dy = zeros(5, 1);
dy(1) = y(2)^2/r - 4*y(2) - 2;
dy(2) = y(2) - y(1) - 2*y(3) + (y(2)*y(3))/r;
dy(3) = 2*y(3) - 2*y(2) + y(3)^2/r;
dy(4) = y(5)*(y(2)/r - 2) - 1;
dy(5) = y(5)*(y(3)/r + 1) - y(4);
要加上那個點,可能y0是'[-1 0 0 0.5 0]' – Rasman 2011-04-26 15:38:07
爲什麼是負數?我試着今晚運行它,並在晚些時候依靠你 – Jo0o0 2011-04-27 01:07:39
我不知道你是如何得出你的方程和初始條件的,但是'-1'使系統穩定,而'1'沒有。當您將'0.5'更改爲'-0.5'時,情況並非如此 – Rasman 2011-04-27 02:31:03