How to solve mass transfer equation with array input
显示 更早的评论
My bass balance equation for the energy loss of a water tank exposed to the sun is the following: M*c_p*dT/dt = Q, where Q is the sum of the energy loss through convection, evaporation and radiation:
Q_conv = h_c*A*(T_w-T)
Q_evap = m*c_p*(100-T_w)*1000/24/3600
Q_rad = sigma*T_w^4*eps_lent*A+G*eps_lent*A;
Where dT/dt, T and G are arrays. I tried to solve the mass balance for T_w (water temperature) using solve(eqn,T_w) but I only get a symbolic 0x1 matrix as an answer with no content. How do I solve this correctly so that I get an array for T_w?
Best regards
回答(1 个)
Star Strider
2017-9-18
1 个投票
You appear to have a system of differential equations. You need to correctly cast your system as a set of differential equations (see the documentation on ode45 to begin with), then solve them numerically using one of the ODE solvers, or (if it has an analytic solution), the Symbolic Math Toolbox dsolve function.
It’s not obvious to me what the variables-of-interest are, so I leave the coding to you.
3 个评论
kwak
2017-9-18
Star Strider
2017-9-18
If you already have the vectors for your variables and just want to calculate the result, that should be straightforward, with a little algebra.
Use the element-wise multiplication and division ‘dot operator’, ‘.*’ and ‘./’ unless you want to do matrix calculations. See Array vs. Matrix Operations (link) for details. The Symbolic Math Toolbox is likely not necessary.
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!