How can I make the loop operation to give only 1 answer for each iteration? Here's my program that i tried out but it keeps giving me more than 2 answer of each iteration.

조회 수: 1 (최근 30일)
f=0;
while f<0.1
f=f+0.0000001;
Re=10^((1/sqrt(f)+0.537)/1.930)/sqrt(f);
for x=25000:-5000:5000
if round(Re)==x
disp(f)
end
end
end

답변 (1개)

KSSV
KSSV 2022년 1월 21일
f=0;
while f<0.1
f=f+0.0000001;
Re=10^((1/sqrt(f)+0.537)/1.930)/sqrt(f);
count = 0 ;
for x=25000:-5000:5000
if round(Re)==x && count == 0
count = count+1 ;
disp([count f])
end
end
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by