Solving differential equation - where is my mistake in my code?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Zeynep Toprak
el 23 de Dic. de 2020
Comentada: Zeynep Toprak
el 23 de Dic. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 23 de Dic. de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Assembly en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!