Help with Periodic functions

2 views (last 30 days)
Chance Morine
Chance Morine on 4 Apr 2021
Commented: darova on 4 Apr 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?

Answers (1)

Chance Morine
Chance Morine on 4 Apr 2021
Found it actually!

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!