Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi am 10 Apr. 2015
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?

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 10 Apr. 2015
Bearbeitet: Roger Stafford am 10 Apr. 2015
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.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by