我正在为一个介绍性编程类编写一个简单的GDL(IDL)代码。它被用来确定人跳伞的速度与时间的关系。它使用Euler近似值,我一直得到一个错误,我确信这与一开始定义变量有关,但我不知道怎么做。(我认为这与FORTRAN中的方法类似,但这对我来说并不起作用。)任何帮助都是非常感谢的。谢谢
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当我尝试运行这段代码时,我得到错误消息
% 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$ 发布于 2014-07-10 15:21:54
我做了一些调整。其一:在分配数组的一个元素(现在是t0和v0)之前,您没有定义数组t或v。第二:h在使用之前没有被定义。还要注意,在IDL中,您可以从0(而不是1)开始。
我不能谈论表达式的数学,但我相信这更接近你想要的。
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
endhttps://stackoverflow.com/questions/23187975
复制相似问题