필터 지우기
필터 지우기

Solving differential equation - where is my mistake in my code?

조회 수: 1 (최근 30일)
Zeynep Toprak
Zeynep Toprak 2020년 12월 23일
댓글: Zeynep Toprak 2020년 12월 23일
function HW_3_Exercise_11_ode_solver()
%Firstly define the given parameters
beta = 0.8; % Maximal expression rate
alpha =0.6; % Degredation rate
K = 0.25; % Activation coefficient
n = 4; % a constant
C0 = 0.1; % Initial concentration at time 0,
[tvals1,cvals1] = ode45(@protein_eqn,[0, 15],C0);
C1 = 0.2; % Another Initial concentration
[tvals2,cvals2] = ode45(@protein_eqn,[0, 15],C1);
figure3 = figure;
axes('Parent',figure3,'FontSize',12);
box('on');
hold('all');
plot(tvals1,cvals1);
hold on
plot(tvals2,cvals2);
title({'Solution to problem #5'},'FontSize',14);
xlabel({'{Time (sec)}'},'FontSize',14,'FontName','Times New Roman');
ylabel({'% Concentration (mols/m^3)'},'FontSize',14,'FontName','Times New Roman');
% Define the function
function dcdt = protein_eqn (C)
dcdt = beta*(C/K)^n/(1+(C/K)^n)- alpha*C;
end
end
But when I run, I obtain the error
Where is my mistake? I cannot handle it? Please le me know my mistake. Thanks

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 23일
ode45() always passes at least two parameters to the ode function: current time, and the boundary conditions.
You are not required to use either of them in your code, but you must accept them:
function dcdt = protein_eqn(~,C)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by