+ Reply to Thread
Results 1 to 4 of 4

Interpolating between degrees

  1. #1
    Registered User
    Join Date
    08-20-2019
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    2

    Interpolating between degrees

    Hi

    I'm trying to come up with a solution to interpolate between wind directions associated with different altitudes.

    The table:
    ALT FL180 FL190 FL200 FL210 FL220 FL240
    DIR 300 x x x x 030

    The values 300 and 030 are examples of user input and the x's should be calculated.

    Wind can veer (change clockwise) or back (change anticlockwise) and I have been trying, unsuccessfully, to account for this.

    When the direction reaches 360 the next point should be 001, and likewise when decreasing from 001 to 360.

    I appreciate any assistance, thanks!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Interpolating between degrees

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    03-28-2018
    Location
    Houston, TX
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    127

    Re: Interpolating between degrees

    Ok. I have attached a solution for you. The green cells are the user inputs, and the four cells between them do the interpolation regardless of direction and does this based on the shortest change. For example, if The user input is 40 and 300 it will not interpolate as 40, 92, 144, 196, 248, 300. It will instead interpolate as 40, 20, 0, 340, 300. I'm assuming this is what you want. The formulas are somewhat complex to understand so here is my basic explanation. If will start with the nested IF().
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This part of the formula is getting the difference between the user inputs and the direction of change from one to the other. It first checks if the difference between the 2 is less than 180 degrees. If it is, then it gets the difference between the two. This is the simplest case because you can directly interpolate between the two without having to cross over the 360 degree mark. If the difference between the 2 is more than 180 degrees, then it check to see which of the 2 numbers is smaller and then it adds 360 degrees to that number and then gets the difference between the two numbers. Now the hard part is done. The rest of the formula is simple.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    For the first formula you take the first input and change it by the above calculated difference and multiply by 1/5 since you are interpolating 4 steps between the two numbers. There are 4 steps between the two numbers (1/5, 2/5, 3/5, and 4/5). Since you want from 1 to 360 and not 0 to 359, I subtract 1 before using MOD (this function gives the remainder when a number is divided by another number... in this case 360) that way it doesn't convert 360 to 0, but it will convert -1 to 359. Then I add one after the MOD is calculated to get you back up to 1 through 360 instead of 0 through 359. Hopefully this helps you understand the formula.

    It is easiest to just open the workbook I attached and see how it all works. Good luck.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-20-2019
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    2

    Re: Interpolating between degrees

    Hi brant.wheeler

    Thank you so much for the solution. My solution had some nested IF statements too but for the life of me I couldn't figure out how to reach 360 and carry on from 0.

    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Best way to convert Degrees Minutes and Seconds to Decimal of Degrees (and Vice Versa)
    By Aussie_Student in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2017, 02:12 AM
  2. Replies: 4
    Last Post: 07-26-2016, 09:06 AM
  3. [SOLVED] how can i convert degrees/minutes/seconds to decimal degrees?
    By russkris in forum Excel General
    Replies: 14
    Last Post: 03-03-2015, 04:32 AM
  4. Replies: 2
    Last Post: 05-04-2013, 07:33 AM
  5. Replies: 4
    Last Post: 09-13-2012, 11:21 AM
  6. Converting Lat/Long (Degrees Minutes Seconds) to Decimal Degrees
    By Jeremy Rayne in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2008, 06:02 PM
  7. Replies: 2
    Last Post: 04-28-2006, 07:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1