how can we solve the iterative functions based on fzero and fsolve simultaneously?

1 次查看(过去 30 天)
Hi, I have a function which has some input parameters which are constant. However, there is one parameter as teta (teta must be calculated from another iterative procedure using fzero, the equations are as follows:
Input parameters:
D=0.030; A=7.0685*10^-4; Jo=0.763; Jw=0.778090833; ro_o=910; ro_w=1000; mu_w=0.001; mu_o=0.92;
The equation is as follows and my task is to calculate Hw, in fact one equation and one unknown Hw, but interesting point is that in my equation there is 'teta' which is a function of Hw as well, I tried to iteratively calculate teta but there is an error, how can I solve it, I wrote:
[Hw, fValue] = fsolve(@(Hw) (((8*ro_o*((D-(2*sqrt(Hw*A/pi)))*(Jo/(1-Hw))*ro_o/mu_o)^-1.0)*(((Jo/(1-Hw))-(Jw/Hw))*((Jo/(1-Hw))-(Jw/Hw))))*(pi*D/2*(2*sin(teta/2)+2*pi-teta)*(1/(1-Hw))))-((0.023*(((Jw*D*ro_w)/mu_w)^-.2)*ro_w*(Jw/Hw)^2*(pi*D))), 0.9);
fun=@(x,Hw) 2*pi*(Hw-1)+x-sin(x); teta=fzero(@(x) fun(x,Hw),[0 2*pi]);
  2 个评论
Parham Babakhani Dehkordi
If I want to do this in one call, I would have one equation with two unknowns meaning Hw and teta, how is it possible?
John D'Errico
John D'Errico 2015-4-9
Pass fsolve a vector of length 2 for the argument vector.
Have the first element be Hw, and the second element be teta.
Then return a vector of length 2 from your objective function.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2015-4-9
This is silly.
Why not solve for ALL of the parameters (that are unknowns) in ONE call to fsolve? To try to interleave the two is giving you problems, and me a headache, for something that is far simpler to do in one call.

类别

Help CenterFile Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by