need help for euler code
조회 수: 8 (최근 30일)
이전 댓글 표시
I have an assignment for tomorrow and been strugling with it for a week. It roughly asks for the vertical position of a mass thrown upward while gravitational acceleration value is changing as x changes. When I put the value 1, it works well. However, it also requires to test input values different from 1 such as 0.1, 10, 100, and they does not work whatsoever. Anybody can help me to fix it?
function[delta] = projectile(tdelta) %first of all I have to construct a funtion.
v0=1800; %an arbitrary v0 value
h=tdelta; %I added this line just because not to get any error
g0=9.8; %gravitational acceleration
Radius=6370; %radius of earth in km
tmax = v0/g0; %this line supossed to be time elapsed until reach the possible max altitude
x=0; %x refers to altitude
for t=0:h:tmax %h value should be the time intervals for euler method.
x=x+h*(v0/1000 - g0*t*((1-h/Radius)^2))); %this part is the where pain starts.
% (v0/1000 - g0*t*((1-h/Radius)^2))) <-- this part is velocity, which is the derivative of x function. gravitational acceleration is changing also.
% g0(1-h/R) is basically gravitational acceleration due to altitude.
plot(t,x)
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Gravitation, Cosmology & Astrophysics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!