Plotting the output from differential equations
5 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to design a program for making a plot using the outcome from differential equations. I have tried to construct a code several times for this, but I failed. Actually, documents on MathWorks for this issue are very confusing. Would you check my code designed to solve coupled differential equations and let me know what commands are needed to make plots? (Two plots should be generated. One for time vs S_1 the other for time vs S_2.)
I think the basic idea of the program is to save each outcome from given differential equations and use the data for plotting, but I don't know.
(Again, the following code is only for solving differential equations, so additional commands are required to plot data.)
syms S_1(t) S_2(t);
K=1;
k_1=20;
k_2=5;
k_3=5;
k_4=5;
k_5=2;
n=4;
dsolve(diff(S_1,t)==k_1*S_2^n/(K^n+S_2^n)-k_3*S_1-k_5*S_1,S_1(0)==0.0);
dsolve(diff(S_2,t)==k_2+k_5*S_1-k_4*S_2,S_2(0)==0.6);
0 个评论
采纳的回答
Walter Roberson
2018-2-14
As I explained in https://www.mathworks.com/matlabcentral/answers/381943-solving-differential-equation-with-initial-conditions#comment_534054 those are related functions and must be dsolve() together. I also indicated there that the functions are effectively impossible to solve in closed form.
You will need to switch to numeric resolution. Star Strider posted links to odeFunction. The first example for odeFunction takes you through the entire workflow of functions needed to convert symbolic ode into inputs for the ode* routines.
2 个评论
Walter Roberson
2018-2-14
In this simple example, dsolve is able to give you a closed form solution. You can store that closed form solution in a variable and fplot() that variable over the desired range.
In the case of the equations in your Question, above, there is no meaningful closed form solution and you will need to follow the work-flow show in odeFunction to translate your ode from symbolic to numeric and do a numeric simulation, which you can then plot.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!