Help with Periodic functions

2 vues (au cours des 30 derniers jours)
Chance Morine
Chance Morine le 4 Avr 2021
Commenté : darova le 4 Avr 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 commentaire
darova
darova le 4 Avr 2021
Please attach the whole code

Connectez-vous pour commenter.

Réponses (1)

Chance Morine
Chance Morine le 4 Avr 2021
Found it actually!

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by