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