using ode45
显示 更早的评论
Dear all,
I would like to solve the following system of differential equations with input with Matlab. I tried with ODE45. Unfortunately, I always get a very strange behaviour of the solution, almost insensitive to the input. The values of the parameters (taus tauf etc..) are taken from a work where integration of the same equations was succesfull, and are supposed to be meaningful. The input should be an impulse at given time. The solution should look null before the impulse, increasing afterwards, reaching zero again after about 20 sec.
It is probably some stupid mistake but I cannot get it right. Any suggestion?
Thanks in advance, Sara
%%---------------------------------
pnts = 7680;
dt = 0.0039;
x0 = zeros(1,2);
u = zeros(pnts,1);
u(768) = 1;
t = [1 pnts]*dt;
[T, SOL] = ode45(@fx, t, x0,[],u,dt);
%% ----------------------------
function dx = fx(t,x,u,dt)
ui = u(ceil(t/dt));
x = x';
taus = 0.8;
tauf = 0.4;
epsilon = 0.5;
dx(:,1) = epsilon*ui-x(:,1)./taus-(x(:,2)-1)./tauf;
dx(:,2) = x(:,2);
dx = dx';
end
%%---------------------------------------------------------------
6 个评论
Andrew Newell
2012-1-24
It might help if you tell us what the equation is that you are trying to solve (in case you're not representing it right).
Sara
2012-1-24
Andrew Newell
2012-1-24
No, I mean something like
dx1/dt = ...
dx2/dt = ...
Sara
2012-1-24
Andrew Newell
2012-1-24
What is u? You have it equal to zero except at one point.
Sara
2012-1-24
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!