我想要时t=0是,theta变为2,怎么改tmin = 0; tmax = 100; % 精度 d_doc = 1; doc = (tmax-tmin)/d_doc; % 参数直接在后面改 Pf = 10; m = 700; ii = 0.025; i0 = 0.02; nx = 45; r = 0.7*0.01; E = 1; theta = 0.1; d = -0.01; gamma = 1; kc = 20; aerfa = 0.7; lamuda = 0.8; fai = 10; beita = 1; w1 = 2; w2 = 1; n = 0.1; P0 = 5; huibig = 25; P1 = -m*beita*(i0+d)*huibig*Pf/(((-fai*theta-(w1-w2)*E-log(n)+i0*beita+d*beita)... *(kc-huibig)*Pf*((-fai*theta-(w1-w2)*E-log(n)+i0*beita)/beita/aerfa)^(aerfa/(aerfa-1)))-beita*m*(i0+d)*E) syms dp T = linspace(tmin,tmax,doc); dt = T(2)-T(1); for i = 1:doc result_p(i) = P0; p = P0; eqn = ( - fai*theta - (w1-w2)*E-log(n)) / beita + i0 - dp/p ... - aerfa*( beita*m*( E*p-huibig*Pf )*(i0+d)/p/(-fai*theta-(w1-w2)*E-log(n)+i0*beita+d*beita)... /(kc-huibig)/Pf)^ ( (aerfa-1)/aerfa ) ==0; temp_dp = solve(eqn,dp) ; temp_dp = double( temp_dp ); temp_dp = ( min( real(temp_dp) ) ); dp1(i) = temp_dp; P0 = P0 + temp_dp*dt; disp(["计算中...",string(i/doc*100)," %"]); end figure plot(T,result_p) xlabel("t") ylabel("p") figure plot(T,dp1); xlabel("t") ylabel("dp") dp_p = dp1./result_p; figure; plot(T,dp_p) xlabel("t") ylabel("dp/p")
时间: 2024-01-05 14:03:27 浏览: 145
要在t=0时将theta更改为2,只需在循环开始前将theta的值更改为2即可。修改后代码如下:
tmin = 0;
tmax = 100;
% 精度
d_doc = 1;
doc = (tmax-tmin)/d_doc;
% 参数直接在后面改
Pf = 10;
m = 700;
ii = 0.025;
i0 = 0.02;
nx = 45;
r = 0.7*0.01;
E = 1;
theta = 2; % 将theta更改为2
d = -0.01;
gamma = 1;
kc = 20;
aerfa = 0.7;
lamuda = 0.8;
fai = 10;
beita = 1;
w1 = 2;
w2 = 1;
n = 0.1;
P0 = 5;
huibig = 25;
P1 = -m*beita*(i0+d)*huibig*Pf/(((-fai*theta-(w1-w2)*E-log(n)+i0*beita+d*beita)...
*(kc-huibig)*Pf*((-fai*theta-(w1-w2)*E-log(n)+i0*beita)/beita/aerfa)^(aerfa/(aerfa-1)))-beita*m*(i0+d)*E)
syms dp
T = linspace(tmin,tmax,doc);
dt = T(2)-T(1);
for i = 1:doc
result_p(i) = P0;
p = P0;
eqn = ( - fai*theta - (w1-w2)*E-log(n)) / beita + i0 - dp/p ...
- aerfa*( beita*m*( E*p-huibig*Pf )*(i0+d)/p/(-fai*theta-(w1-w2)*E-log(n)+i0*beita+d*beita)...
/(kc-huibig)/Pf)^ ( (aerfa-1)/aerfa ) ==0;
temp_dp = solve(eqn,dp) ;
temp_dp = double( temp_dp );
temp_dp = ( min( real(temp_dp) ) );
dp1(i) = temp_dp;
P0 = P0 + temp_dp*dt;
disp(["计算中...",string(i/doc*100)," %"]);
end
figure
plot(T,result_p)
xlabel("t")
ylabel("p")
figure
plot(T,dp1);
xlabel("t")
ylabel("dp")
dp_p = dp1./result_p;
figure;
plot(T,dp_p)
xlabel("t")
ylabel("dp/p")
阅读全文