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