need help for euler code
Show older comments
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
Answers (0)
Categories
Find more on Geoscience in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!