How to plot a differential equation?
조회 수: 35 (최근 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!