' <<< PLOT01.BAS >>> ' Program to plot on the GDC512 or Microangelo graphics screens the data entered and function calculated by the ' complimentary program PLOT.BAS. Program written by J. V. Brancik of Univ. N. S. W. ' Dimensions (X%()=abs.lims. of screen; G%()=info flgs; XD(),YD()=exptl. data; X,Y=fnc.points; DX(),DY()=ranges; DIM X%(4),G%(12),XD(7,40),YD(7,40),X(400),Y(7,400),DX(7),DY(7),LIM(7,9):' (LIM()=limits) ' Equates (margins left, right, bottom and top, respectively, and format string) X%(0)=61:X%(1)=471:X%(2)=48:X%(3)=458:L$="####":' coordinates of the default plotting area in abs. units, format STATP%=241:DATP%=240:' status and data ports for the graphics card GOTO 6000:' where the Main section of this program is and from where all the subroutines are called. Watch for the ' selection of PAGE DISPLAY and PAGE EDIT - if your system does not support pages then comment out the ' line which sets the DISPLAY and EDIT to the PAGE ONE. ' Subroutine section ' ================== ' Subroutine to cause delay (graphics screen refresh time - needed only when drawing frames around the screen) ' Check your system, perhaps you will not need it. My system has 3 graphics cards are from SME Systems (company you ' never heard of) connected together with color mixing card giving altogether 6 pages of graphics, each page 512X490 ' pixels - and the delay is needed because somehow the handshake is not perfect. Some of the codes are the same ' as for the Microangelo graphics card and only those are used here. So NO color or page swapping or animation ' or other gimmics are used here. 1000 FOR delay=1 TO 500:NEXT:return:' needed only for drawing frames, this is for 6MHz CPU, change to suit ' Subroutines to handle the screen editing functions ' -------------------------------------------------- ' Codes are for the Televideo terminal 1100 PRINT CHR$(27)CHR$(42):RETURN:' clear the whole screen 1110 GOSUB 1130:PRINT CHR$(27)CHR$(89):GOSUB 1130:RETURN:' clear to the end of screen from the current cursot position 1120 GOSUB 1130:PRINT CHR$(27)CHR$(84):GOSUB 1130:RETURN:' clear to the end of line from the current cursot position 1130 PRINT CHR$(27)CHR$(61)CHR$(M%+31)CHR$(N%+31);:RETURN:' direct cursor address (set the cursor position) ' Subroutines to handle the data files and data ' --------------------------------------------- ' Subroutine to open a data file for random access, F$=filename, FL%=rec length 1500 OPEN"R",#1,F$,FL%:FIELD#1,FL% AS R$:RETURN ' Subroutine to read experimental points from the data file (always the default filename PLOT.$$$) ' xd(i,j) is the x-value of i-th set and j-th pair, yd(i,j) is the y-value of i-th set and j-th pair 1510 FOR I%=0 TO G%(3)-1:K%=I%*80:FOR J%=1 TO G%(4+I%):GET#1,2*J%-1+K%:XD(I%,J%)=CVS(R$):GET#1,2*J%+K% YD(I%,J%)=CVS(R$):NEXT:NEXT:CLOSE:RETURN:' always room for 40 pairs of data per each set ' Subroutine to read points for the function to be plotted ' x(j) is the x-coordinate of the j-th function point and y(i,j) is the y-coordinate of the j-th function point be- ' longing to the i-th set (of data) 1520 FOR J%=1 TO 400:GET#1,J%:X(J%)=CVS(R$):NEXT:FOR I%=1 TO G%(3):FOR J%=1 TO 400:K%=J%+400*I%:_ GET#1,K%:Y(I%-1,J%)=CVS(R$):NEXT:NEXT:CLOSE:RETURN:' x's are the same for all f(x)'s ' Subroutine to read data for the graphics screen setup ' lim(set no.,0) = x-coord of axis intersection lim(set no.,1) = y-coord of axis intersection ' lim(set no.,2) = X(min) lim(set no.,3) = X(max) ' lim(set no.,4) = Y(min) lim(set no.,5) = Y(max) ' lim(set no.,6) = number of x-axis divisions lim(set no.,7) = number of y-axis divisions ' lim(set no.,8) = function minimum lim(set no.,9) = function maximum ' lim(set no.,10) = x-tick % above x-axis lim(set no.,11) = x-tick % below x-axis ' lim(set no.,12) = y-tick % right of y-axis lim(set no.,13) = y-tick % left of y-axis ' here we read only up to lim(set no.,9) - there is no need play with axis ticks 1530 M%=22:N%=1:GOSUB 1110:INPUT"Type K to use keyboard, D data file for graphics screen setup:",A$ IF A$="K" THEN RETURN ELSE IF A$="D" THEN 1535 ELSE 1530 1535 GOSUB 1110:LINE INPUT"Filename is ",F1$:IF F1$="" THEN F$="PLOT0"+MID$(STR$(G%(1)),2,1)+".SET" ELSE F$=F1$ FL%=40:GOSUB 1500:FOR I%=0 TO 7:GET#1,I%+1:Q$=R$:FOR J%=0 TO 9:' we read lims for all 8 sets regardless LIM(I%,J%)=CVS(MID$(Q$,1+4*J%,4)):NEXT:NEXT:CLOSE:RETURN ' Subroutine to write data for the graphics screen set-up into a file ' (for explanation look on subroutine 1530) 1540 M%=22:N%=1:GOSUB 1110:LINE INPUT"Filename is ",F1$:IF F1$="" THEN F$="PLOT0"+MID$(STR$(G%(1)),2,1)+".SET" ELSE F$=F1$ FL%=40:GOSUB 1500:FOR I%=0 TO 7:Q$="":FOR J%=0 TO 9:' we write data for all 8 sets regardless Q$=Q$+MKS$(LIM(I%,J%)):NEXT:LSET R$=Q$:PUT#1,I%+1:NEXT:CLOSE:RETURN ' Subroutine to calculate minima and maxima of experimental points (to determine upper and lower limits) ' this is just for user's information when deciding about the plotting limits 1600 FOR I%=0 TO G%(3)-1:LIM(I%,2)=XD(I%,1):LIM(I%,3)=XD(I%,1):LIM(I%,4)=YD(I%,1):LIM(I%,5)=YD(I%,1):' for all sets FOR J%=1 TO G%(4+I%):' in each set IF XD(I%,J%)<=LIM(I%,2) THEN LIM(I%,2)=XD(I%,J%) ELSE IF XD(I%,J%)>=LIM(I%,3) THEN LIM(I%,3)=XD(I%,J%):' min IF YD(I%,J%)<=LIM(I%,4) THEN LIM(I%,4)=YD(I%,J%) ELSE IF YD(I%,J%)>=LIM(I%,5) THEN LIM(I%,5)=YD(I%,J%):' max NEXT:DX(I%)=LIM(I%,3)-LIM(I%,2):DY(I%)=LIM(I%,5)-LIM(I%,4):NEXT:RETURN ' Subroutine to calculate minima and maxima of functions (lim(i,8)=f(min), lim(i,9)=f(max)) ' this is just for user's information when deciding about the plotting limits 1610 FOR I%=1 TO G%(3):LIM(I%-1,8)=Y(I%-1,1):LIM(I%-1,9)=Y(I%-1,1):FOR J%=1 TO 400 IF Y(I%-1,J%)<=LIM(I%-1,8) THEN LIM(I%-1,8)=Y(I%-1,J%) ELSE IF Y(I%-1,J%)>=LIM(I%-1,9) THEN LIM(I%-1,9)=Y(I%-1,J%) NEXT:NEXT:RETURN ' Subroutine to calculate absolute units for screen plotting ' x%(0) is the x axis offset (in absolute units) x%(2) is the y axis offset (in absolute units) ' xd is the x-value in user units yd is the y-value in user units ' lim(set,2) is the x(min) in user units lim(set),4) is the y(min) in user units ' dx(set) = x(max)-x(min) in user units dy(set) = y(max-y(min) in user units ' xspan = (max no. of units on x-axis)-x%(0) yspan = (max no. of units on y-axis)-x%(2) 1620 X=X%(0)+(XD-LIM(SET%-1,2))/DX(SET%-1)*XSPAN:Y=X%(2)+(YD-LIM(SET%-1,4))/DY(SET%-1)*YSPAN:RETURN:'XD,YD in user units ' Subroutine to keep plotting within specified limits (window) 1630 IF LIM%=0 THEN RETURN:' axis, legends, title and notes are outside the limits IF YDLIM(SET%-1,5) THEN YD=LIM(SET%-1,5) RETURN:' just draw line on the limit (upper or lower one) ' Subroutine to display the exit menu 1700 M%=22:N%=1:GOSUB 1110:INPUT"Type R to repeat the routine or type E to exit: ",A$ IF A$<>"R" THEN IF A$<>"E" THEN 1700:' only capital letters are accepted IF A$="R" THEN GOSUB 5040:ON G%(1) GOSUB 6110,6210,6310,6410:' repeat routines (nested GOSUB no ret to here) RETURN:' exiting and chaining ' Subroutines to setup the graphics screen ' ---------------------------------------- ' Subroutine to display heading 3000 GOSUB 1100:M%=1:N%=1:GOSUB 1130:PRINT"<";F1$;">":M%=2:GOSUB 1130:print string$(76,61):M%=1 IF G%(1)=1 THEN A$="Plot of experimental points":N%=INT(40-(LEN(A$))/2):GOSUB 1130:PRINT A$ IF G%(1)=2 THEN A$="Plot spline functions":N%=INT(40-(LEN(A$))/2):GOSUB 1130:PRINT A$ IF G%(1)=3 THEN A$="Plot regression function":N%=INT(40-(LEN(A$))/2):GOSUB 1130:PRINT A$ IF G%(1)=4 THEN A$="Plot user defined function":N%=INT(40-(LEN(A$))/2):GOSUB 1130:PRINT A$ M%=1:N%=INT(76-LEN(F2$)):GOSUB 1130:PRINT"<";F2$;">":RETURN ' Subroutine to display and change the graphics screen data (abs. plotting units) ' This one is for the GDC-512 which has 512x490 pixels. Change to suit. ' NOTE - the gdc512 has actually two screens 512x419 pixels each, but only one can be displayed at time. For the ' compatibility reason only ONE page is used here. See also note at label 6000. 3100 M%=4:N%=1:GOSUB 1130:PRINT"Total plotting area is 512 X 490 abs. units.":M%=5:GOSUB 1130 PRINT"The default plotting area (in abs. units):";:PRINT USING L$;X%(1)-X%(0);:PRINT" X"; PRINT USING L$;X%(3)-X%(2):M%=7:N%=5:GOSUB 1130:PRINT"X(start), abs. units: ";:PRINT USING L$;X%(0):M%=8 GOSUB 1120:PRINT"X(end), abs. units: ";:PRINT USING L$;X%(1):M%=9:GOSUB 1120:PRINT"Y(start), abs. units: "; PRINT USING L$;X%(3):M%=10:GOSUB 1120:PRINT"Y(end), abs. units: ";:PRINT USING L$;X%(3):GOSUB 5070 M%=22:N%=1:GOSUB 1120:INPUT"OK (Y)? ",A$:IF A$<>"N" THEN RETURN ELSE 3110 3110 N%=35:FOR M%=7 TO 10:GOSUB 1130:INPUT"? ",A$:IF A$=""THEN 3120 ELSE X%(M%-6)=VAL(A$) 3120 NEXT:M%=4:N%=1:GOSUB 1110:GOSUB 5040:GOSUB 1000:GOSUB 4060:GOSUB 4070:GOTO 3100:' change data, show new frame ' Subroutine to display and change limits for plots 3200 M%=2:N%=1:GOSUB 1110:' clear to the end of page M%=5:N%=4:GOSUB 1110:PRINT"X(0), (user units): ":M%=6:GOSUB 1120:PRINT"Y(0), (user units): " M%=8:N%=4:GOSUB 1120:PRINT"X(MIN), (user units): ":M%=9:GOSUB 1120:PRINT"X(MAX), (user units): " M%=10:GOSUB 1120:PRINT"Y(MIN), (user units): ":M%=11:GOSUB 1120:PRINT"Y(MAX), (user units): " M%=13:GOSUB 1120:PRINT"X-divisions: ":M%=14:GOSUB 1120:PRINT"Y-divisions: " M%=16:GOSUB 1120:PRINT"min of F(x), (user units): ":M%=17:GOSUB 1120:PRINT"max of F(x), (user units): " M%=4:N%=30:FOR I%=0 TO 9:M%=M%+1:GOSUB 1130:IF I%=1 OR I%=5 OR I%=7 THEN M%=M%+1 PRINT STR$(LIM(SET%-1,I%)):NEXT 3210 M%=22:N%=1:GOSUB 1110:INPUT"OK (Y/N)?",A$:IF A$<>"N" and A$<>"Y" THEN 3210 IF A$="Y" THEN 3220 ELSE 3230 3220 GOSUB 1110:INPUT"Save the data (N)?",A$:IF A$<>"Y" THEN return else GOSUB 1540:RETURN:' save data? 3230 GOSUB 1530:IF A$="K" THEN 3240 ELSE 3200:' fill-in the name of the file with limits/change lims from KB 3240 M%=4:FOR I%=0 TO 7:M%=M%+1:N%=32+LEN(STR$(LIM(SET%-1,I%))):GOSUB 1130 IF I%=1 OR I%=5 THEN M%=M%+1:' just for readable spacing between data INPUT" ";A$:IF A$="" THEN 3250 ELSE LIM(SET%-1,I%)=VAL(A$):' RET means no change, else type the data 3250 NEXT:GOTO 3200:' when change finished, display again changed values (end of change lims. sub.!) ' Subroutines to perform the graphics ' ----------------------------------- ' Subroutine to plot experimental points on the graphics screen (as little crosses) 4000 F1$="plot dots":GOSUB 3000:M%=4:N%=1:GOSUB 1110:M%=22:GOSUB 1120:INPUT"Draw points (Y)? ",A$:IF A$="N" THEN RETURN FOR I%=1 TO G%(3+SET%):XD=XD(SET%-1,I%)-.01*DX(SET%-1):YD=YD(SET%-1,I%):GOSUB 1620:GOSUB 5060 XD=XD(SET%-1,I%)+.01*DX(SET%-1):GOSUB 1620:GOSUB 5080:XD=XD(SET%-1,I%):YD=YD(SET%-1,I%)-.01*DY(SET%-1) GOSUB 1620:GOSUB 5060:YD=YD(SET%-1,I%)+.01*DY(SET%-1):GOSUB 1620:GOSUB 5080:NEXT:RETURN ' Subroutine to draw axis at XD(SET%,0),YD(SET%,0) 4010 f1$="draw axis":GOSUB 3000:M%=4:N%=1:GOSUB 1110:M%=22:GOSUB 1120:INPUT"Draw axis (Y)? ",A$:IF A$="N" THEN RETURN LIM%=0:XD=LIM(SET%-1,2):YD=LIM(SET%-1,1):GOSUB 1620:GOSUB 5060:XD=LIM(SET%-1,3):GOSUB 1620:GOSUB 5080 XD=LIM(SET%-1,0):YD=LIM(SET%-1,4):GOSUB 1620:GOSUB 5060:YD=LIM(SET%-1,5):GOSUB 1620:GOSUB 5080:LIM%=1:RETURN ' Subroutine to draw ticks and labels 4020 f1$="draw labels":GOSUB 3000:M%=4:N%=1:GOSUB 1110:M%=22:GOSUB 1120:INPUT"Draw ticks and labels (Y)? ",A$ IF A$="N" THEN RETURN else LIM%=0:FOR I%=0 TO LIM(SET%-1,6):XD=LIM(SET%-1,2)+I%*DX(SET%-1)/LIM(SET%-1,6) YD=LIM(SET%-1,1)+.01*DY(SET%-1):GOSUB 1620:GOSUB 5060:YD=LIM(SET%-1,1)-.01*DY(SET%-1):GOSUB 1620:GOSUB 5080 YD=LIM(SET%-1,1)-.05*DY(SET%-1):GOSUB 1620:GOSUB 5060:MODE%=0:GOSUB 5100:FOR J%=2 TO LEN(STR$(XD)) BIT%=ASC(MID$(STR$(XD),J%,1)):GOSUB 5090:NEXT:NEXT:M%=39:N%=45-LEN(X$)/2:GOSUB 5050:FOR J%=1 TO LEN(X$) BT%=ASC(MID$(X$,J%,1)):GOSUB 5010:NEXT:FOR I%=0 TO LIM(SET%-1,7):YD=LIM(SET%-1,4)+I%*DY(SET%-1)/LIM(SET%-1,7) XD=LIM(SET%-1,0)-.01*DX(SET%-1):GOSUB 1620:GOSUB 5060:XD=LIM(SET%-1,0)+.01*DX(SET%-1):GOSUB 1620:GOSUB 5080 XD=LIM(SET%-1,0)-.1*DX(SET%-1):GOSUB 1620:GOSUB 5060:MODE%=0:GOSUB 5100:FOR J%=1 TO LEN(STR$(YD)) BIT%=ASC(MID$(STR$(YD),J%,1)):GOSUB 5090:NEXT:NEXT:LIM%=1:RETURN ' Subroutine to draw a title of the plot; for the plot points and plot spline functions options the title can be ' entered from the keyboard, but for the regression function the title is stored in a sequential file PLOT03.DOC. ' There are 8 records of numerical values of the regression coefficients of the respective models. 4030 IF G%(1)=3 THEN 4050:' to a special routine for the regression functions 4040 M%=22:N%=1:GOSUB 1120:INPUT"Legend (Y/N)",A$:IF A$<>"Y" THEN IF A$<>"N" THEN IF A$<>"" THEN 4040:'ret=same legend IF A$="N" THEN X$="" ELSE IF A$="Y" THEN LINE INPUT"(max. 80 chars.) ",X$:' type the new legend GOSUB 1100:RETURN:' N cancells the previous legend 4050 OPEN"I",#1,"PLOT03.DOC":' open the file and read the appropriate record (model number is in the SET% variable) FOR REC%=1 TO SET%:INPUT#1,A$:NEXT:CLOSE:X$=A$:RETURN:' then get the record, close file and return ' Subroutine to draw a frame around the whole graphics screen (not really needed all the time) ' the dealy subroutine is called from here, if you are going not to use this routine the comment out the delay too 4060 X=0:Y=0:GOSUB 5060:X=511:GOSUB 5080:GOSUB 1000:Y=489:GOSUB 5080:GOSUB 1000:X=0:GOSUB 5080:GOSUB 1000 Y=0:GOSUB 5080:RETURN ' Subroutine to draw a frame around the plotting area (not really needed all the time) ' the dealy subroutine is called from here, if you are going not to use this routine the comment out the delay too 4070 X=X%(0):Y=X%(2):GOSUB 5060:X=X%(1):GOSUB 5080:GOSUB 1000:Y=X%(3):GOSUB 5080:GOSUB 1000:X=X%(0):GOSUB 5080 Y=X%(2):GOSUB 5080:RETURN ' Subroutines to handle the GDC-512 Graphics board ' ------------------------------------------------ ' bt% is a byte send to the board, wd% is a word send to the board ' Subroutines to send data to the GDC-512 board ' (The Status port is 241 and the Data port is 240. Change to suit.) 5000 BT%=INT(WD%/256):GOSUB 5010:BT%=(WD% AND 255):GOSUB 5010:RETURN:' Subroutine to output a 16-bit data 5010 IF (INP(STATP%) AND 1)>0 THEN 5010 ELSE OUT(DATP%),(BT% AND 255):RETURN:' Subroutine to output a 8-bit data ' Subroutine to clear graphics and reset alpha cursor 5040 M%=22:N%=1:GOSUB 1110:INPUT"Clear graphics (N)? ",a$:if a$<>"Y" then return OUT(STATP%),1:OUT(STATP%),0:BT%=136:GOSUB 5010:BT%=12:GOSUB 5010:RETURN ' Subroutine to set position of the alpha cursor 5050 BT%=129:GOSUB 5010:BT%=M%:GOSUB 5010:BT%=N%:GOSUB 5010:RETURN ' Subroutine to set graphics cursor to x,y coordinates 5060 BT%=132:GOSUB 5010:WD%=X:GOSUB 5000:WD%=Y:GOSUB 5000:RETURN ' Subroutine to reset the GDC512 but not to clear the graphics 5070 OUT(STATP%),1:OUT(STATP%),0:GOSUB 1000:RETURN ' Subroutine to draw a line from the current position to x,y 5080 BT%=145:GOSUB 5010:WD%=X:GOSUB 5000:WD%=Y:GOSUB 5000:RETURN ' Subroutine to plot character at current location of graphics cursor 5090 BT%=152:GOSUB 5010:BT%=BIT%:GOSUB 5010:RETURN ' Subroutine to set character mode; direction, size, normal/reverse video 5100 BT%=153:GOSUB 5010:BT%=MODE%:GOSUB 5010:RETURN ' The MAIN section of the program ' =============================== 6000 GOSUB 1100:M%=22:N%=1:GOSUB 1120:F$="PLOT.FLG":FL%=2:GOSUB 1500:GET#1,1:G%(0)=CVI(R$):FOR I%=1 TO G%(0):GET#1,I%+1:' read flags G%(I%)=CVI(R$):NEXT:CLOSE:IF G%(2)=1 THEN 6010:' choice of graphing on screen and plotter or on plotter only INPUT"Plot on Graphics Screen too (N)";A$:IF A$<>"Y" THEN CHAIN"PLOT02.COM":' chain to plotter program 6010 GOSUB 1100:' the following line can be commented out if your system does not support pages BT%=186:GOSUB 5010:BT%=3:GOSUB 5010:' select screen 0 for display and edit F2$="Screen set-up":GOSUB 3000:GOSUB 3100:XSPAN=X%(1)-X%(0):YSPAN=X%(3)-X%(2):GOSUB 5040:' screen set-up FOR I%=0 TO 7:LIM(I%,6)=10:LIM(I%,7)=10:NEXT:ON G%(1) GOTO 6100,6200,6300,6400:' set divs., then branch ' The final branching point, all routines end here to chain complimentary programs 6050 IF G%(2)>1 THEN CHAIN"PLOT02.COM" ELSE KILL"PLOT.FLG":CHAIN"PLOT.COM" ' routine to plot experimental points and connect these (if required) by a line 6100 F$="PLOT.$$$":FL%=4:GOSUB 1500:GOSUB 1510:GOSUB 1600:M%=2:N%=1:GOSUB 1110:' read data, get min/max, cls 6110 M%=22:N%=1:GOSUB 1120:PRINT"There are";G%(3);:INPUT" set(s) of data. Which set to plot";A$:SET%=VAL(A$) IF SET%<1 OR SET%>G%(3) THEN 6110:' check for validity of the number of sets F2$="set no.:"+STR$(SET%):GOSUB 1100:GOSUB 3000:GOSUB 3200:' display header, get the plotting limits DX(SET%-1)=LIM(SET%-1,3)-LIM(SET%-1,2):DY(SET%-1)=LIM(SET%-1,5)-LIM(SET%-1,4) GOSUB 4000:M%=22:N%=1:GOSUB 1110:INPUT"Connect these points by lines (Y)? ",A$:IF A$="N" THEN 6120 XD=XD(SET%-1,1):YD=YD(SET%-1,1):GOSUB 1620:GOSUB 5060:FOR I%=2 TO G%(3+SET%):XD=XD(SET%-1,I%):YD=YD(SET%-1,I%) GOSUB 1620:GOSUB 5080:NEXT:' set graphics cursor to first point, then draw line from point to point 6120 GOSUB 4030:GOSUB 4010:GOSUB 4020:GOSUB 1700:GOTO 6050:' do axis and labels and (if required) legend, repeat? ' plot spline function routine (one set of data for f(x), f'(x), f''(x); set no.=function to plot) 6200 G%(3)=1:F$="PLOT.$$$":FL%=4:GOSUB 1500:GOSUB 1510:GOSUB 1600:' read exptl points, calc min/max G%(3)=3:F$="PLOT02.DAT":GOSUB 1500:GOSUB 1520:GOSUB 1610:' read all functions points, calc all min/max SET%=1:FOR I%=0 TO 7:LIM(I%,6)=10:LIM(I%,7)=10:LIM(I%,2)=LIM(0,2):LIM(I%,3)=LIM(0,3):NEXT:' defaults xmin/xmax 6210 GOSUB 1100:GOSUB 3000:M%=22:N%=1:GOSUB 1120:INPUT"Type F to plot f(x), D1 to plot f'(x), D2 to plot f''(x) ",A$ IF A$<>"F" THEN IF A$<>"D1" THEN IF A$<>"D2" THEN 6210:' choose function to plot IF A$="D1" THEN SET%=2:F2$="plot of f'(x)":GOSUB 3000:GOSUB 3200:' get limits IF A$="D2" THEN SET%=3:F2$="plot of f''(x)":GOSUB 3000:GOSUB 3200:' get limits IF A$="F" THEN SET%=1:F2$="plot of f(x)":GOSUB 3000:GOSUB 3200:' function plot DX(SET%-1)=LIM(SET%-1,3)-LIM(SET%-1,2):DY(SET%-1)=LIM(SET%-1,5)-LIM(SET%-1,4):IF SET%=1 THEN GOSUB 4000:' dots? XD=X(1):YD=Y(SET%-1,1):GOSUB 1620:GOSUB 5060:FOR I%=2 TO 400:XD=X(I%):YD=Y(SET%-1,I%):GOSUB 1620:GOSUB 5080:NEXT GOSUB 4030:GOSUB 4010:GOSUB 4020:GOSUB 1700:GOTO 6050:' ask for legend, draw axis with labels and ticks, repeat? ' family regression analysis routine (one data set for all 8 models; set no. is model no.) 6300 G%(3)=1:F$="PLOT.$$$":FL%=4:GOSUB 1500:GOSUB 1510:GOSUB 1600:' read all the data, calc min/max FOR I%=1 TO 7:G%(I%+4)=G%(4):FOR J%=1 TO G%(4):XD(I%,J%)=XD(0,J%):YD(I%,J%)=YD(0,J%):NEXT:NEXT FOR I%=1 TO 7:FOR J%=0 TO 9:LIM(I%,J%)=LIM(0,J%):NEXT:NEXT:' exptl data the same for all 8 models G%(3)=8:F$="PLOT03.DAT":GOSUB 1500:GOSUB 1520:GOSUB 1610:' get points and limits for all models, calc min/max 6310 GOSUB 1100:F1$="":F2$="regression models":GOSUB 3000:M%=3:N%=8:GOSUB 1120:PRINT"1. Y = A + B * X":M%=5:GOSUB 1120 PRINT"2. Y = A + B / X":M%=7:GOSUB 1120:PRINT"3. (1/Y) = A + B * (1/X)":M%=9:GOSUB 1120 PRINT"4. Y = B * X^(1/2)":M%=11:GOSUB 1120:PRINT"5. Y = A * exp(B * X)":M%=13:GOSUB 1120:PRINT"6. Y = A * X^B" M%=15:GOSUB 1120:PRINT"7. Y = A + B * ln(X)":M%=17:GOSUB 1120:PRINT"8. Y = A + B * X + C * X^2" 6320 M%=22:N%=1:GOSUB 1110:INPUT"Type the number of your selected regression model: ",A$:SET%=VAL(A$) F2$="model no."+STR$(SET%):IF SET%<1 OR SET%>8 THEN 6320:' get legal limits else loop GOSUB 3200:FOR L%=0 TO 7:DX(L%)=LIM(L%,3)-LIM(L%,2):DY(L%)=LIM(L%,5)-LIM(L%,4):NEXT:GOSUB 4000:' lims, plot points XD=X(1):YD=Y(SET%-1,1):GOSUB 1630:GOSUB 1620:GOSUB 5060:FOR I%=2 TO 400:XD=X(I%):YD=Y(SET%-1,I%):GOSUB 1630 GOSUB 1620:GOSUB 5080:NEXT:GOSUB 4030:GOSUB 4010:GOSUB 4020:GOSUB 1100:GOSUB 3000::' draw plot, cls, header GOSUB 1700:GOTO 6050:' repeat or end this routine? ' plot user's function routine ' Here we can have up to 8 sets of experimental data for 8 sets of functions. We read only those experimental data ' that were entered BUT we read ALL 8 sets of function points regardless 6400 GOSUB 1100:' cls, display header, if any experimantal data then read them IF G%(2)<3 THEN F$="PLOT.$$$":FL%=4:F1$=F$:GOSUB 3000:GOSUB 1500:GOSUB 1510:GOSUB 1600:' read data, min/max G%=8:SWAP G%,G%(3):F$="PLOT04.DAT":FL%=4:F1$=F$:GOSUB 3000:GOSUB 1500:GOSUB 1520:GOSUB 1610:swap g%,g%(3) FOR L%=0 TO 7:DX(L%)=LIM(L%,3)-LIM(L%,2):DY(L%)=LIM(L%,5)-LIM(L%,4):NEXT:' get proper x nad y ranges 6410 GOSUB 3000:M%=3:N%=1:GOSUB 1110:IF G%(2)<3 THEN 6420 ELSE 6430:' if no data then function perhaps 6420 M%=22:N%=1:GOSUB 1120:PRINT"There are";G%(3);:INPUT" set(s) of data. Which set to plot";A$ SET%=VAL(A$):F2$="Set no."+STR$(SET%):IF SET%<1 OR SET%>8 THEN 6410:' set proper plotting limits and plot points GOSUB 3000:GOSUB 3200:DX(SET%-1)=LIM(SET%-1,3)-LIM(SET%-1,2):DY(SET%-1)=LIM(SET%-1,5)-LIM(SET%-1,4):GOSUB 4000 ' Here we draw a function curve. It is assumed here that the user knows how many curves to plot. There is NO ' checking on validity of the data - unwritten data will be read and plotted 6430 M%=22:N%=1:GOSUB 1120:INPUT"Plot function for set number: ",A$:A=VAL(A$):IF A=0 THEN GOSUB 1700:' exit perhaps? IF A<1 OR A>8 THEN 6430 ELSE SET%=A:' we have an existing function number F2$="Set no."+STR$(SET%):GOSUB 3000:GOSUB 3200:DX(SET%-1)=LIM(SET%-1,3)-LIM(SET%-1,2):' get new ranges DY(SET%-1)=LIM(SET%-1,5)-LIM(SET%-1,4):XD=X(1):YD=Y(SET%-1,1):GOSUB 1630:GOSUB 1620:GOSUB 5060:'set graphics cursor FOR I%=2 TO 400:XD=X(I%):YD=Y(SET%-1,I%):GOSUB 1630:GOSUB 1620:GOSUB 5080:NEXT:' draw the function GOSUB 4030:GOSUB 4010:GOSUB 4020:GOSUB 1100:GOSUB 3000:' title?, axis?, ticks and labels?, cls, display header GOSUB 1700:GOTO 6050:' repeat or end this routine? END