Help with Periodic functions

2 visualizaciones (últimos 30 días)
Chance Morine
Chance Morine el 4 de Abr. de 2021
Comentada: darova el 4 de Abr. de 2021
Hello everyone. I have a question with a system of differential equations. I am trying to solve them using Euler's method. The functions are as follows.
dT1 = @(t,T1,T2) (((Ain*Qin)-((k2*(T1-T2+5))*A2)-((k1*(T1-Tout(t)))*A1))/(Cair*rho*V1));
dT2 = @(t,T1,T2) ((((k2*(T1-T2+5))*A2)-((k3*(T2-Tout(t)))*A3))/(Cair*rho*V2));
Where tout is a periodic function as follows.
Tout = @(t) -10*sin((2*pi*t)/(86400));
and the for loop for Euler's method.
i=1;
for i = 1:N-1
t(i+1) = t(i) + h;
T1(i+1) = T1(i+1)+h*dT1(t(i),T1(i),T2(i));
T2(i+1) = T2(i+1)+h*dT2(t(i),T1(i),T2(i));
end
The issue im running into is with the plot of T1 and T2. The periodic function is working correctly. But since T1 and T2 are defined with a periodic function, they should also be periodic. However, I am getting a completelely linear response. Any ideas?
  1 comentario
darova
darova el 4 de Abr. de 2021
Please attach the whole code

Iniciar sesión para comentar.

Respuestas (1)

Chance Morine
Chance Morine el 4 de Abr. de 2021
Found it actually!

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by