How to plot a differential equation?
    17 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Pravin Jagtap
    
 on 29 Apr 2020
        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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
