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일

0 개 추천

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일
I don't think the problem is the linspace as it gives me the row with values I need Rey is ofcourse defined in my code, but the problem regards the loop, I'd like to know what does the eror mean, again that being
Array indices must be positive integers or logical values. which particulary refers to my If cylce
if Fm(i)-Fm(i+1)<= abs(10^-6)
I have answered based on the error
Array indices must be positive integers or logical values.
With this line space i= linspace(0.0001,0.0009,1000)
if Fm(i)-Fm(i+1)<= abs(10^-6)
This does not work
Say i=0.0001, that is first value
Fm(i)>>Fm(0.0001) does it have any menaing
%...^................^ ...these are called indices of an array, it must be non zero positive interger.
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일

1 개 추천

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')

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2019년 5월 19일

편집:

2019년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by