Compute steady states as a funciton of k, ODE
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I will write a function called "compute_states" that takes as input a value for k and then returns as output ALL real-valued steady states for the ODE. The function will be assessed by running "Ceq = compute_states(k)" for many different values of k. I also want to be sure to filter out any complex-valued steady states. I know that "roots" and "imag" might be helpful.
Input: a scalar for k
Output: a vector of steady states, where the lenght of the vector is the number of all real-valued steady states.
ODE: dC/dt = 0.1*(C-20)*(23-C)*(C-26) +k
What I have so far:
Function:
function vectCeq = compute_states(k)
% note that vectCeq is a vector of all real-valued steady states
end
Code to call my function:
k=0; % try for different values of k
vectCeq = compute_states(k)
0 comentarios
Respuestas (1)
Anurag
el 24 de Nov. de 2023
Hi Erik,
I understand that you need to compute all real valued steady states of given ordinary differential equation. For that you need to set the right-hand side of the equation to zero and solve for “C”.
Here is an example code snippet that you can refer to:
function vectCeq = compute_states(k)
% Define the polynomial coefficients (using coeffs of the equation you
% have written)
coefficients = [0.1,−6.9,145−k,−520];
% Find the roots of the polynomial equation
roots_eq = roots(coefficients);
% Filter out complex roots and keep only real roots
real_roots = roots_eq(imag(roots_eq) == 0);
% Remove duplicate roots (if any)
vectCeq = unique(real_roots);
% Display the results
disp(['For k = ', num2str(k), ', real-valued steady states:']);
disp(vectCeq);
end
k = 0; % or any other value
vectCeq = compute_states(k);
This function calculates the real-valued steady states for the given value of k and displays the results.
Documentation link for the function used:
Hope this helps!
Regards,
Anurag
2 comentarios
Tommy
el 6 de Abr. de 2024
May I ask how you got those coefficients (Line 4)? I'm not getting the same
Ver también
Categorías
Más información sobre Ordinary Differential Equations 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!