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 visualización (últimos 30 días)
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

Respuestas (1)

KSSV
KSSV el 21 de En. de 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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by