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 Ansicht (letzte 30 Tage)
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

Antworten (1)

KSSV
KSSV am 21 Jan. 2022
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

Kategorien

Mehr zu Loops and Conditional Statements 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