fork download
  1. function degreedays(x0,h)
  2. x=x0; maxtime=30; numsteps=100000;
  3. for n=1:numsteps
  4. if x<1
  5. x=x+h*0.004*(28+5*cos(2*pi*(n-1)*h)-15);
  6. else
  7. break
  8. end
  9. end
  10.  
  11. x
  12. days=n*h
  13. end
  14.  
  15. degreedays(0, 0.01)
  16. degreedays(0, 0.001)
  17. degreedays(-12, 0.002)
  18. degreedays(-25, 0.005)
  19.  
Success #stdin #stdout 5.41s 65056KB
stdin
Standard input is empty
stdout
x =  1.0003
days =  19.190
x =  1.0000
days =  19.177
x = -1.6000
days =  200
x =  1.0000
days =  500