フィルターのクリア

How can I apply 'for' cycle for two arrays?

1 回表示 (過去 30 日間)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2015 年 4 月 10 日
Hello,
I have these parameters:
D=0.030;
A=7.0685*10^-4;
Jo=0.763;
Jw=[0.778090833 0.998156927 1.194644511 1.395061847 1.583689928 1.772318008 1.964875841 2.369640264];
ro_o=910;
ro_w=1000;
mu_w=0.001;
mu_o=[1.057 1.079 1.057 1.117 1.086 1.050 1.057 0.993];
and the function as:
Hw = 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*sqrt(Hw*A./pi)))*(1/(1-Hw))))-((0.023*(((Jw*D*ro_w)/mu_w)^-.2)*ro_w*(Jw/Hw)^2*(pi*D))), 0.9)
For each value of Jw and mu_o, there must be one value of Hw, how can I write 'for' loop to take into consideration of two vectors Jw and mu_o?

採用された回答

Roger Stafford
Roger Stafford 2015 年 4 月 10 日
編集済み: Roger Stafford 2015 年 4 月 10 日
It depends on what you mean by "For each value of Jw and mu_o". If you mean for each of eight corresponding pairs of numbers from these two vectors, do this:
for k = 1:8
Hw(k) = fsolve(@(Hw) .....mu_o(k).....Jw(k).....
end
If you mean for each of the sixty-four possible combination of pairs from these two arrays, then do:
for k1 = 1:8
for k2 = 1:8
Hw(k1,k2) = fsolve(@(Hw) .....mu_o(k1).....Jw(k2).....
end
end
Let us hope that the initial estimate of 0.9 will lead to successful convergence for all cases.
There is also the possible problem of multiple solutions for this equation.
  1 件のコメント
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2015 年 4 月 12 日
I meant the first case. Thanks, it works

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by