Results 1 to 4 of 4

Interpolation of 2D Array

Threaded View

  1. #1
    Registered User
    Join Date
    01-31-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    2

    Post Interpolation of 2D Array

    Hello there!

    I am trying to figure out how to interpolate a 2D data array using VBA with the data being kept within of a macro.

    Below, the T (y) and C (x) is chosen by the user (two cells with the information) and the A_rho is the combined rho variables.

    VBA Data (dataset can be changed if needed, this is just how I set it up)
    C = Array(1, 2, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 50)
    T = Array(0, 15, 20, 40, 60, 80, 100)
    rho_0 = Array(1.0124, 1.0244, 1.0482, 1.0943, 1.1399, 1.1849, 1.2296, 1.2741, 1.3182, 1.3614, 1.403, 1.4435, 1.4825, 1.521, 1.54)
    rho_15 = Array(1.01065, 1.02198, 1.04441, 1.08887, 1.13327, 1.17761, 1.22183, 1.26582, 1.3094, 1.352, 1.3933, 1.4334, 1.472, 1.5102, 1.529)
    rho_20 = Array(1.0095, 1.0207, 1.0428, 1.0869, 1.1309, 1.1751, 1.2191, 1.2629, 1.3064, 1.349, 1.39, 1.43, 1.4685, 1.5065, 1.5253)
    rho_40 = Array(1.0033, 1.0139, 1.0352, 1.078, 1.121, 1.1645, 1.2079, 1.2512, 1.2942, 1.3362, 1.3768, 1.4164, 1.4545, 1.4922, 1.5109)
    rho_60 = Array(0.9941, 1.0045, 1.0254, 1.0676, 1.1101, 1.1531, 1.196, 1.2388, 1.2814, 1.3232, 1.3634, 1.4027, 1.4405, 1.4781, 1.4967)
    rho_80 = Array(0.9824, 0.9929, 1.0139, 1.056, 1.0983, 1.1408, 1.1833, 1.2259, 1.2682, 1.3097, 1.3498, 1.3889, 1.4266, 1.4641, 1.4827)
    rho_100 = Array(0.9693, 0.9797, 1.0009, 1.0432, 1.0855, 1.1277, 1.17, 1.2124, 1.2546, 1.296, 1.336, 1.375, 1.4127, 1.4503, 1.469)
    A_rho = Array(rho_0, rho_15, rho_20, rho_40, rho_60, rho_80, rho_100)
    I am able to do this with Matlab, but not with a VBA function.

    Matlab code with an internal interp2 file looks something like this
      interpolated=(TT,cc) interp2(T,C,A_rho,TT,cc);
      rho_F = interpolated(T2,C2)
    Note: at sign after interpolated= is removed due to forum thinking it is a link.

    Example:
    A1 = T2 = 20
    A2 = C2 = 42
    A3 = output = 1.4492

    I can figure the interpolation out if the data is in the excel already, but when the data is inside the code, I am very unsure. Any suggestions would be great.

    Cheers!
    Last edited by svensvba; 02-05-2019 at 05:45 AM. Reason: SOLVED

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Linear Interpolation of a Multidimensional Array
    By sperry2565 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-20-2013, 05:15 PM
  2. 2D interpolation
    By o0tintin0o in forum Excel General
    Replies: 1
    Last Post: 04-02-2012, 03:41 PM
  3. **3D Interpolation x,y,z -> f(x,y,z)**
    By kidongee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-15-2011, 06:59 AM
  4. Interpolation
    By rehan0129 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2010, 12:44 AM
  5. Expanding an array....Interpolation?
    By gannon_w in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2008, 12:36 PM
  6. Replies: 0
    Last Post: 07-24-2008, 02:27 PM
  7. [SOLVED] interpolation in an array
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-12-2005, 11:45 PM
  8. [SOLVED] help with interpolation and limit of interpolation
    By uriel78 in forum Excel General
    Replies: 0
    Last Post: 02-18-2005, 10:06 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