Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : LINE GRAPH Command with optional limits?
Author | Message | ||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1109 |
The LINE GRAPH command is proving quite useful for drawing, well, graphs. LINE GRAPH x(),y(),colour This command generates a line graph of the coordinate pairs specified in “x()” and “y()”. The graph will have n-1 segments where there a n elements in the x and y arrays. Would it be possible to add an extra optional parameter specifying n where n is <= the number of elements in the arrays? Even better would be another parameter, m, specifying the starting element. The benefit would be two-fold: the ability plot just a window in the full data set, and to not require the entire array to be filled with valid data. ---------- I can see benefits to many of the commands/functions that act on arrays having starting and ending element number parameters. For example, Math(max arrayname(),m,n) would pick out the max value in the specified window. And yes, much of this can be done with variations on math set a(m),b() ' fill all of b() with useful data but that's a bunch of extra error prone steps and can't be faster than existing commands with start/end parameters would be.addr1 = Peek(VARADDR a()) addr2 = Peek(VARADDR b()) Memory COPY FLOAT addr1 + m*8, addr2, n ' copy some of a() to b() maxval = Math(max b()) Thank you for considering this! Visit Vegipete's *Mite Library for cool programs. |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2127 |
I used line graph for a game. "Would it be possible to add an extra optional parameter specifying n where n is <= the number of elements in the arrays?" it does I think. "Even better would be another parameter, m, specifying the starting element." 'til then copy from start to another array? dim integer lx(43)=(0,5,9,13,3,18,25,30,48,53,57,47,32,11,5,9,57,89,108,149,170,220,262,300,320,400,447,493,510,545,572,600,638,605,590,577,560,513,495,470,457,500,639) ' dim integer ly(43)=(0,7,15,25,40,70,100,130,130,160,193,253,298,346,420,430,430,400,370,457,450,400,440,466,424,400,460,460,452,403,373,320,240,210,190,170,130,120,137,110,60,26,0) Line GRAPH lx(),ly() |
||||
Print this page |