![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/373056/image.png)
Ploting two differential equations
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
How can I plot the 2 functions?
dydt(1)=-2.*y.*t;
dydt(2)=3.*y-(2/exp(1)).*exp(t);
0 comentarios
Respuestas (1)
Ameer Hamza
el 6 de Oct. de 2020
Editada: Ameer Hamza
el 6 de Oct. de 2020
These seems to be two independent ODEs. Try following code
IC = [2 -3]; % initial condition
tspan = [0 10];
[t, y] = ode45(@odefun, tspan, IC);
subplot(2,1,1)
plot(t, y(:,1))
legend('First Equation');
subplot(2,1,2)
plot(t, y(:,2))
legend('Second Equation');
function dydt = odefun(t, y)
dydt(1)=-2.*y(1).*t;
dydt(2)=3.*y(2)-(2/exp(1)).*exp(t);
dydt = dydt(:);
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/373056/image.png)
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!