why is my code not working?

2 visualizzazioni (ultimi 30 giorni)
Franco Belletti
Franco Belletti il 18 Mag 2019
Commentato: Walter Roberson il 19 Mag 2019
I'd like to get the index (i) for wich the condition I set in the foor loop appears on the results
Fm0= linspace(0.01,0.02,100);
%ciclo iterativo
for i=1:100
for Fm= (0.25).*(((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm0).^-1))))).^-1).*((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm0).^-1)))))).^-1)
if Fm(i)-Fm0<=10^-6
break
end
end
end

Risposta accettata

Walter Roberson
Walter Roberson il 18 Mag 2019
Fm0 = linspace(0.01,0.02,100);
Fm= (0.25).*(((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm0).^-1))))).^-1).*((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm0).^-1)))))).^-1)
i = find( Fm-Fm0 <= 10^-6, 1);
You will find that the answer is 1 -- Fm0(1) > Fm(1) so the subtraction is negative and so satisfies the condition.
You might perhaps have been thinking,
i = find( abs(Fm-Fm0) <= 10^-6, 1);
but you will find that this is empty.
  2 Commenti
Franco Belletti
Franco Belletti il 19 Mag 2019
thanks!
Walter Roberson
Walter Roberson il 19 Mag 2019
If you are looking for the value of Fm such that
Fm = (0.25).*(((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm).^-1))))).^-1).*((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(Fm).^-1)))))).^-1)
then the value turns out to be complex, at least for positive Rey (I did not experiment with negative Rey.)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Thermal Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by