Help with double for loop
1 view (last 30 days)
Show older comments
Hi y'all
I have a problem in which I must use a double for loop for this equation:
roCpdT/dt=-vxroCpdT/dx-UA(T-Tv)
It's for a heat exchanger where :
- ro density of water
- Cp Heat capacity of water
- dT/dt Change of temperature as a function of time
- vx Flux velocity inside the inner tube of the heat exchanger
- dT/dx Change of temperature as a function of space
- U Global heat transfer coefficient
- A Trasnfer area
- T Temperature of a certain point in space at a certain time
- Tv Steam temperature
So, I must use a double ¨for¨ loop to graph the function between x = [0 40] meters and within a time of t = [0 : 100 : 2000] seconds. Please, How can I do it using the Euler method, and also, how can I plot the results (Preferebly 1 curve per time interval)? Thanks!
2 Comments
Answers (1)
darova
on 22 Feb 2021
I'll give you a start
T= zeros(m,n); % preallocation
T(1,:) = % initial condition
for i = 1:m-1
for j = 1:n-1
T(i+1,j+1) = T(i,j+1) + dt/dx*Vx*(T(i,j+1)-T(i,j)) - UA*(T(i,j+1)-Tv)
end
end
note: dt/dx part should be small
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!