0

I am writing a simple GDL(IDL) code for an introductory programming class. It is used to determine the velocity of a man parachuting in relation to time. It uses an Euler approximation and I keep getting an error that I am sure has something to do with defining my variables at the beginning but I don’t know how to. (I imagine it is something similar to the way its done in FORTRAN but that hasn’t worked for me.) Any help is appreciated. Thanks

pro para

print,"enter inital time"
read,t(1)
print,"enter initial velovity"
read,v(1)
print,"enter drag coefficient"
read,c
print,"enter mass"
read,m

for i=1,10 do begin
v(i+1)=v(i)+(32-(c*v(i)*v(i))/m)*(h)
h=((t(i)+1)-t(i))
t(i+1)=t(i)+1
endfor

for j=1,11 do print,t(j),v(j)
endfor
end

When I try and run this code I get the error message

% Ambiguous: Function not found: T  or: Variable is undefined: T
% Execution halted at: $MAIN$          
% Ambiguous: Function not found: V  or: Variable is undefined: V
% Execution halted at: $MAIN$          
Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
csb391
  • 13
  • 4

1 Answers1

0

I've made a couple adjustments. One: you hadn't defined the arrays t or v before assigning one of their elements (now t0 and v0). Two: h wasn't defined prior to its usage. Also, note you can start from 0 (instead of 1) in IDL.

I can't speak on the mathematics of the expression but I believe this is closer to what you were going for.

pro para

print,"enter inital time"
read,t0
print,"enter initial velovity"
read,v0
print,"enter drag coefficient"
read,c
print,"enter mass"
read,m

t=make_array(11,/double,value=0)
v=make_array(11,/double,value=0)
t[0] = t0
v[0] = v0

for i=0,10 do begin
    h=((t(i)+1)-t(i))
    v(i+1)=v(i)+(32-(c*v(i)*v(i))/m)*(h)
    t(i+1)=t(i)+1
    print,t[i],v[i]
endfor

end
koma
  • 1
  • 1
  • 1