Solving differential equation - where is my mistake in my code?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zeynep Toprak
am 23 Dez. 2020
Kommentiert: Zeynep Toprak
am 23 Dez. 2020
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/469517/image.png)
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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 23 Dez. 2020
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assembly finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!