Post Reply 
Have you used your calculator for something that was not really math related?
03-16-2017, 01:03 PM
Post: #38
RE: Have you used your calculator for something that was not really math related?
(03-09-2017 09:48 AM)brickviking Wrote:  I don't quite know if this is math-related or not, but here goes. One really simple thing I use my HP50G for is to keep a list of V1/Vr/V2/Vfr speeds in an array which I feed with table data, i.e. I look up the weight and flaps from a paper table, get speeds, put them into the array. Trying to automate that is considerably beyond me and my current programming skills on UserRPL (practically non-existent).

Does anyone have any suggestions for that? I've got all the relevant data, I'm even prepared to input the whole lot into the calculator, but what I don't know how to do is to correlate that for input values of weight, flaps, altitude and temperature. The way I would have done it in bash (a scripting language) would have been to create large arrays and simply report which value matches most closely. On a stack-based language, that's a bit more difficult.

(Post 56)

Here is a simple way to lookup values from tables. Nothing polished, just to give you an idea.

1) Create a variable 'SPD' with a list of lists with mass and speeds.
Each sub-list contains the mass as its first element and then the associated speeds. The first element is the one which is used for the lookup.
(do not type in the comments shown at the right)
Code:


  { 14. 100. 101. 102. }              for 14 tons
  { 15. 101. 102. 103. }              for 15 tons
  { 16. 102. 103. 104. }              for 16 tons
  { 99. 0. 0. 0. }                    for all above 16 tons (ERROR)
}
'SPD' STO

2) Create a simple lookup program. This program takes the mass from the stack and then walks through the list of speeds.
It stops when the next higher speed is found. I.e. if the table contains masses of 14 and 15 tons, and the actual mass given is 14.5 then the values for the higher speed (15 tons) will be returned.
I used the INFORM dialog to show the results. If the dialog is closed with "OK" the selected sub-list with the values is returned, in case of cancel nothing is returned.
The input mass is also left on the stack.

Code:

« 1. SPD SIZE                      setup the for loop, based on the size of the 'SPD' list
  FOR 
  I DUP SPD I GET 1. GET           get each mas from the list and compare with the given mass
  ≤ IF
    THEN I 9999. 'I' STO SPD SWAP GET             if found: stop by storing a high value into the loop count 'I'
    END                                           and put the sub-list on the stack
  NEXT 
  
  "Speeds"                                        prepare input for INFORM
  { { "Mass" "tons" 0. } 
    { "V1" "kts" 0. }                             one {} for each entry in sublist
    { "V2" "kts" 0. }
    { "Vr" "kts" 0. } } 
  { 1. 6. }                                       for alignment
  { }
  5. ROLL                                         put sub-list in proper position
  INFORM                                          show results
  DROP                                            get rid of OK/Cancel flag
»
'GETV' STO
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Have you used your calculator for something that was not really math related? - Martin Hepperle - 03-16-2017 01:03 PM



User(s) browsing this thread: 2 Guest(s)