How to plot a differential equation?
22 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
I would like to plot the following differential equation.
k= 1.4*10^-11;
a=0.25;
c=0.25;
U_ptox=0.76;
R=8.314;
F=96485;
T= 350;
U=0.85;
etha= -U + U_ptox;
syms y(t);
dsolve(diff(y,t) == k*((1-y)*exp(((a*F)/(R*T))*etha)-y*exp(((-c*F)/(R*T))*etha)), y(0)==0);
ezplot(y,[0,120]);
Its giving me some errors and i don't know how to fix it.
Can someone help me? Thanks in advance
0 件のコメント
回答 (1 件)
Pravin Jagtap
2020 年 4 月 29 日
Hello,
You need to save the result of 'dsolve' and use it for plotting. Refer to the following code which will help you understand the usage of 'dsolve':
% Constants
k= 1.4*10^-11;
a=0.25;
c=0.25;
U_ptox=0.76;
R=8.314;
F=96485;
T= 350;
U=0.85;
etha= -U + U_ptox;
% System y(t)
syms y(t);
% Equation
eq = diff(y,t) == k*( (1-y)*exp(((a*F)/(R*T))*etha)-y*exp(((-c*F)/(R*T))*etha));
% Condition
cond = y(0)==0;
S = dsolve(eq,cond);
% Plot
ezplot(S,[0,120]);
Also, refer to the following link for more details:
Hope this will help you
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!