我用来解决一个简单的 ode 函数。代码如下。
function window_sine
% Some constant values to be used later in the code.............
epsilon0=8.85*10^-12;
d_mos=0.65*10^-9;
epsilon_mos_min=5*epsilon0;
epsilon_mos_max=20*epsilon0;
d_g=10*10^-9;
epsilon_g=30*epsilon0;
epsilon_mos=5*epsilon0;
vt=0;
e=1.6*10^-19;
n=[];
i=1;
u=30; % cm^2/v*S
h=1.05*10^-34; % j*s
cond_d=e^2/h;
%tIME Step...........
step=0.1;
t = 0:step:10;
%Some other constant values..simple..............
c_g=(epsilon_g/d_g);
c_mos=(epsilon_mos/d_mos);
c_t=1/((1/c_g)+(1/c_mos));
% This below equation involves time "t" which is defined above.
vs=(1-(c_t/c_g))*t;
%ode function calling............
p0=0.01;
[t,p] = ode45(@state,t,p0);
%plotting the result..................
figure
plot(t,p)
title('State Variable')
%Now the Ode45 function.................
function dpdt = state( t,p)
nc=6.8*10^12;
smooth=1;
vg=t;
k=10^-1;
window1=1-((2*p)-1).^(2*smooth);
% How to incorporate the time dependent "n" value here..........
dpdt=k*(n-nc)*window1;
end
end
现在问题是函数中的“n”。它的时间相关及其值可以使用以下代码单独计算。
while i<length(t)
n(i)=((c_g*(t(i)-vs(i)-vt))/e)*(10^-4);% this 10^-4 is for cm^2 unit
i=i+1;
end
简而言之,“n”的值随着“t”线性增加。需要注意的是,“t”在任何地方都是相同的,即导数中使用的时间。
问题是如何将这个时间相关的“n”值合并到我写“n”的 ode 函数中。? 这部分代码在哪里写,在功能块中还是在主代码中?谢谢