home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / tech / jbl / plotfunc.bas < prev    next >
Encoding:
BASIC Source File  |  1979-12-31  |  1.7 KB  |  65 lines

  1. 70 SCREEN 2 : KEY OFF : CLS
  2. 80 PRINT"DO YOU WANT INSTRUCTIONS ?   (TYPE Y OR N)
  3. 90 INPUT I$
  4. 100 IF I$= "N" OR I$="n" THEN 220
  5. 110 PRINT"This program displays the graph of any equation drawn on a grid on 
  6. 120 PRINT"the screen.  The equation must be entered at line 450.  Your equation
  7. 140 PRINT"must use variable Y as the dependent variable and X as the independent
  8. 150 PRINT"variable (e.g., Y=6*X+20).
  9. 160 PRINT"Once your equation has been entered and you type run, you will be asked
  10. 170 PRINT"to specify the minimum and maximum X coordinates and Y values that can
  11. 200 PRINT"appear on the grid.
  12. 210 PRINT
  13. 220 PRINT"Does line 450 contain your equation ?   (Y or N)
  14. 230 INPUT E$
  15. 240 IF E$="Y" OR E$="y" THEN 300
  16. 250 IF E$="N" OR E$="n" THEN 780
  17. 260 PRINT
  18. 270 PRINT"Type '450', followed by your equation, hit return, then the F2 key
  19. 290 GOTO 780
  20. 300 'Plots the equation
  21. 310 PRINT
  22. 320 PRINT"Enter min and max X values, separated by a comma
  23. 340 INPUT XL,XR
  24. 350 PRINT
  25. 360 PRINT"Enter min and max Y values, separated by a comma
  26. 380 INPUT YB,YT
  27. 390 GOSUB 520 'go draw the grid
  28. 410 XA=(564-84)/XD
  29. 420 YA=(180-20)/YD
  30. 430 FOR XG=84 TO 564
  31. 440   X=XL+(XG-84)/484*XD
  32. 450   Y=X^3-27*X
  33. 460   YG=180-(Y-YB)*YA
  34. 470   IF YG<20 OR YG>180 THEN 490
  35. 480   PSET(XG,YG)
  36. 490 NEXT XG
  37. 500 LOCATE 1,1
  38. 510 GOTO 780
  39. 520 'grid subroutine
  40. 530 CLS
  41. 550 FOR Y=20 TO 180 STEP 32
  42. 560 LINE(74,Y)-(574,Y)
  43. 570 NEXT Y
  44. 580 FOR X=84 TO 564 STEP 96
  45. 590 LINE(X,12)-(X,188)
  46. 600 NEXT X
  47. 610 XD=XR-XL
  48. 620 YD=YT-YB
  49. 630 R=23
  50. 640 FOR K=0 TO 5
  51. 650   LOCATE R,1
  52. 660   S=YB+YD*K/5
  53. 670   PRINT USING"####.##";S
  54. 680   R=R-4
  55. 690 NEXT K
  56. 700 C=7
  57. 710 FOR K=0 TO 5
  58. 720   LOCATE 25,C
  59. 730   S=XL+XD*K/5
  60. 740   PRINT USING"####.##";S;
  61. 750   C=C+12
  62. 760 NEXT K
  63. 770 RETURN
  64. 780 END
  65.