Not a enough input arrugment error
조회 수: 1 (최근 30일)
이전 댓글 표시
function [t, Receptor_concentration, C_LigandReceptor] = Simulation_LR1(Kf1Max, Kf1Min, Kf1Tau_on, Kf1Tau_off, Kb1Max, Kb1Min, Kb1Tau_on, Kb1Tau_off, T_startLigand, T_endLigand, timespan)
% Initial Values
Receptor_concentration = 100;
C_LigandReceptor = 0;
% Define anonymous functions for forward and backward reaction rates
kf_1 = @(t) calculate_kf(t, T_startLigand, T_endLigand, Kf1Max, Kf1Min, Kf1Tau_on, Kf1Tau_off);
kb_1 = @(t) calculate_kb(t, T_startLigand, T_endLigand, Kb1Max, Kb1Min, Kb1Tau_on, Kb1Tau_off);
% Solve the ODE system
[t, y] = ode45(@(t, y) ode_LR(t, y, kf_1, kb_1), timespan, [Receptor_concentration; C_LigandReceptor]);
% Extract the concentrations
Receptor_concentration = y(:, 1);
C_LigandReceptor = y(:, 2);
% Displaying the peak value and its corresponding time
[peak_value, peak_time_idx] = max(C_LigandReceptor);
time_to_peak = t(peak_time_idx);
% Find steady state and time to approach 50% of the steady state
steady_state_window = t >= (T_endLigand - 50) & t <= T_endLigand; % Consider the last 50 points
steady_state = mean(C_LigandReceptor(steady_state_window));
% Calculate T-50: Time to reach 50% of the peak value
half_peak_value = (steady_state + peak_value) / 2;
% Find the indices where the ligand receptor concentration is closest to half the peak value
[~, idx_50_percent] = min(abs(C_LigandReceptor - half_peak_value));
% Get the time corresponding to the closest index
time_to_50_percent = t(idx_50_percent) - T_startLigand; % Adjusted to consider the time from T_startLigand
% Find the ratio of the R*peak/R* steady state
peak_to_steady_state_ratio = peak_value / steady_state;
% Find the ratio of the R*peak/R* steady state
Delta = peak_value - steady_state;
end
function kf_L = calculate_kf(t, T_startLigand, T_endLigand, Kf1Max, L_Active, L_min, TauKFON, TauKFOFF)
% Initialize kf_LMin
Kf_LMin = Kf1Max * (L_min / (L_min + 1));
% Initialize kf_L
Kf_L = Kf1Max * (L_Active / (L_Active + 1));
% Initial phase: Constant value Kf_LMin
if t < T_startLigand
kf_L = Kf_LMin;
% Increasing phase: Exponential growth from Kf_LMin to Kf_LMax
elseif t >= T_startLigand && t < T_endLigand
kf_L = Kf_LMin - (Kf_L - Kf_LMin) * exp(TauKFON * (t - T_startLigand));
% Decreasing phase: Exponential decay from Kf_LMax to Kf_LMin
else
kf_end = Kf1Max - (Kf_L - Kf_LMin) * exp(TauKFOFF * (T_endLigand - T_startLigand));
kf_L = Kf_LMin + (kf_end - Kf_LMin) * exp(TauKFOFF * (t - T_endLigand));
end
end
function kb_1 = calculate_kb(t, T_startLigand, T_endLigand, Kb1Max, Kb1Min, TauKBON, TauKBOFF)
% Initialize kb_1
% Initial phase: Constant value Kb1Min
if t < T_startLigand
kb_1 = Kb1Min;
% Increasing phase: Exponential growth from Kb1Min to Kb1Max
elseif t >= T_startLigand && t < T_endLigand
kb_1 = Kb1Min + (Kb1Max - Kb1Min) * exp(TauKBON * (t - T_startLigand));
% Decreasing phase: Exponential decay from Kb1Max to Kb1Min
else
kb_end = Kb1Max - (Kb1Max - Kb1Min) * exp(TauKBOFF * (T_endLigand - T_startLigand));
kb_1 = kb_end + (Kb1Min - kb_end) * exp(TauKBOFF * (t - T_endLigand));
end
end
function dydt = ode_LR(t, y, kf_1, kb_1)
% Unpack the concentrations
Receptor_concentration = y(1);
C_LigandReceptor = y(2);
% Define the ODE system
dReceptor_dt = -kf_1(t) * Receptor_concentration + kb_1(t) * C_LigandReceptor;
d_CLigandReceptor_dt = kf_1(t) * Receptor_concentration - kb_1(t) * C_LigandReceptor;
% Pack the derivatives into a column vector
dydt = [dReceptor_dt; d_CLigandReceptor_dt];
end
댓글 수: 1
Walter Roberson
2024년 2월 2일
if t < T_startLigand
kf_L = Kf_LMin;
The mathematics of Runge-Kutta calculations requires that all of the components of the calculations are C2 differentiable. When you use if testing the time, you seldom match the second derivative (most of the time you do not even match the first derivative.)
You need to break up your ode45 call into three parts, tspan [0 T_startLigand] then tspan [T_startLigand T_endLigand] then tspan [T_endLigand timespan(end)]
답변 (1개)
Sai Teja G
2024년 2월 2일
Hi,
It appears that the error you're encountering is due to the absence of function calls in the code you've provided. The issue arises because you're executing an .m file that contains function definitions without actually invoking the function, resulting in undefined variables. To address this, please ensure that you call the functions either from the command line or within another .m file, and then verify the output of your code.
Hope this helps!
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!