why is my code not working?

1 回表示 (過去 30 日間)
Franco Belletti
Franco Belletti 2019 年 5 月 19 日
編集済み: madhan ravi 2019 年 5 月 19 日
I should make an iterative cylce, yet when trying to run it gives me this error
Array indices must be positive integers or logical values.
for i= linspace(0.0001,0.0009,1000)
Fm= (0.25).*(((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(i).^-1))))).^-1).*((log((2.7*10^-5)+(2.51.*((Rey.*sqrt(i).^-1)))))).^-1);
if Fm(i)-Fm(i+1)<= abs(10^-6)
break
end
end

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 5 月 19 日
編集済み: KALYAN ACHARJYA 2019 年 5 月 19 日
i= linspace(0.0001,0.0009,1000)
%.................^ ...........^............
Array indices must be non zero positive integer
like
linspace(1,1,1000)
Aprat from the above issue there is undefined function or variable 'Rey'. Ensure that it is there in your complete code.
  4 件のコメント
Franco Belletti
Franco Belletti 2019 年 5 月 19 日
crystal clear thanks!
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 5 月 19 日
Welcome @Franco If your question is answered, you can give credit to the answer by accepting it.

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

その他の回答 (1 件)

madhan ravi
madhan ravi 2019 年 5 月 19 日
編集済み: madhan ravi 2019 年 5 月 19 日
Probably you want (no loops needed):
ii = linspace(0.0001,0.0009,1000);
Fm = (0.25).*(((log((2.7*10^-5)+...
(2.51.*((Rey.*sqrt(ii).^-1))))).^-1).*((log((2.7*10^-5)...
+(2.51.*((Rey.*sqrt(ii).^-1)))))).^-1);
First_encounter = find(abs(Fm(1:end-1)...
-Fm(2:end))<= 1e-6,1,'first')

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by