首页 > 解决方案 > 为什么我的第三个 MATLAB 函数在使用 ode45 时只输出零?

问题描述

我需要使用 MATLAB 为我的系统生物学课模拟基因的负、正和简单调控。问题是负调节功能和简单调节功能有效,而正调节功能仅输出零。

我的脚本如下:

% Simulation of simple regulation, negative autoregulation and positive
% autoregulation

% Define constants
global a b K n 
a = 1;
b = 1;
K = 0.5;
n = 2; % Hill coefficient


% Simulation time
tspan = [0,10];

% Initial condition
X0 = 0;

% Run simulations
[t1,X1] = ode45(@autoregulation_f0,tspan,X0); % Simple regulation
[t2,X2] = ode45(@autoregulation_f1,tspan,X0); % Negative autoregulation
[t3,X3] = ode23(@autoregulation_f2,tspan,X0); % Positive autoregulation
% Plot results
figure;
plot(t1,X1,t2,X2,t3,X3);
legend('simple','negative','Location','southeast');

我的功能是:

function dxdt = autoregulation_f0(t,X)
    global a b
    dxdt = b - a*X;
end


function dxdt = autoregulation_f1(t,X)
    global a b K n
    dxdt = b/(1+(X^n)/(K^n)) - a*X;
end

function dxdt = autoregulation_f2(t,X)
    global a b K n 
    dxdt = b*X.^n./(K.^n+X.^n) + a*X;
end

第三个函数“autoregulation_f2(t,X)”是输出零的函数,因此在绘制图形时我只得到一条直线。

有谁知道这可能是什么原因造成的?

提前致谢!

标签: matlabmodelingodeode45

解决方案


它看起来是给定函数的正确结果。您提供的每学期dxdt都有一个X。最初的X0=0结果是dxdt=0,给你没有变化X。结果,您最终会得到一条平坦的线。


推荐阅读