SCREEN 12 VIEW (1, 40)-(638, 348), 8, 4 'Grey box, red border WINDOW (0, -40)-(10, 40) 'Scale 0 to 10, -40 to 40 LINE (0, 0)-(100, 0), 1 'Axis in blue PRINT "Simulation of a second order open-loop system with `live input'" PRINT "Press number keys 0 to 9 to change the input; try to follow the blue line." dt = .00001 'Make dt larger to speed up running x = 10 'Initial values for x v = 0 'and v t = 0 u = -.2 'Initial value of u until a key is pressed PSET (0, x) DO a$ = INKEY$ 'These two lines change the value IF a$ > " " THEN u = 4 * (VAL(a$) - 5) 'of u whenever a key is pressed x = x + v * dt 'This is the simulation v = v + u * dt ' t = t + dt LINE -(t, x) 'This displays the result LOOP UNTIL t > 10