How to plot a differential equation?

22 visualizaciones (últimos 30 días)
Nick987
Nick987 el 26 de Abr. de 2020
Respondida: Pravin Jagtap el 29 de Abr. de 2020
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

Respuestas (1)

Pravin Jagtap
Pravin Jagtap el 29 de Abr. de 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

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!