Info

此问题已关闭。 请重新打开它进行编辑或回答。

IF statement inside a FOR loop ERROR

7 次查看(过去 30 天)
smol2332
smol2332 2018-10-21
关闭: smol2332 2018-10-21
Using h as the FOR loop index variable, begin h at a value of 7,000,000 meters and decreasing h in steps of 0.01 meters, to 4,750,000 meters.
Use the IF statement to detect the first instance when the value of g is within 0.000001 m/s2of 2.53 m/s2. This will be the IF statement’s test. When g and go are that close, then you have found 'h'.
clear; clc; re=6371000; go=9.81; h=700000; x=0; n=1; w=1;
for m =1:n for q=1:w
g=go*((re/(re+h))^2);
if (abs(2.53 - g) < 1e-6)
x=h;
else
w=w+1;
h=h-0.01;
end
end
end
x

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by