solving iterative equations in matlab

6 次查看(过去 30 天)
For a heat exchanger modelling, I would like to give different equations into the Matlab, and solve the unknowns with respect to equations' relationship. For example these are different equations, and parameters:
. . .
rhogi=rhogo*Pin1g*Tout1g/(Pout1g*Tin1g);
rhog=0.5*(rhogo+rhogi);
Gg=m1g/**Aflow**;
Dh=4***Aflow**/n*pi*Do;
Redh=Gg*Dh/nug;
fo=(delpag-(Gg^2*(1/rhogo-1/rhogi)))*rhog*0.5*Dh/(L*Gg^2);
ratio=Redh/Red;
fo=f*ratio^-0.2; %f=0.046*Redh^-0.2
h=0.95*Ga*0.5*f*(power(Pra,-2/3));
ho=cpg*Gg*0.5*fo*(power(Prg,-2/3));
X=Do/D;
UAh=UA/(h*n*pi*D*L);UAho=UA/(ho.n.pi.Do*L);
UAho=1-Uah;
Adim=**Aflow**/n*D^2;
...
, and among them for example "Aflow" shall exist in three different equations; but in the first line, Matlab stops due to "undefined variable Aflow". I need Matlab to go over all the equations, and find Aflow itself. How can I handle this?

回答(1 个)

Walter Roberson
Walter Roberson 2016-3-6
There are three approaches:
  1. Use the Symbolic Toolbox with symbolic equations and use dsolve() or like routines to find a symbolic solution if possible. This would involve defining Aflow as a symbolic variable and solving for it
  2. Use iterative equations. Initialize Aflow to something (0 perhaps) and run a calculation using that value and use the results of the calculation to refine the Aflow value, repeating this process until Aflow stabilizes, indicating consistent equations
  3. Use an ODE routine such as ode45() or ode15s() or possibly bvp4c() depending what you are trying to do.
  7 个评论
fert
fert 2016-3-6
Lets forget about the "solve" function. How can I solve this with "for" loops?
Walter Roberson
Walter Roberson 2016-3-6
After you defined Do as being a symbol, you used
Do=1.2*D;
which redefined it in terms of the symbol D. It is now an expression rather than a symbol by itself, so it cannot be solved for.
Caution: you define
fo=(delpag-(Gg^2*(1/rhogo-1/rhogi)))*rhog*0.5*Dh/(L*Gg^2);
but a couple of lines later you have
fo=f*ratio^-0.2; %f=0.046*Redh^-0.2
which redefines fo as being completely different. There is no point in calculating the first expression if you are going to change the variable before even using it ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by