+ Reply to Thread
Results 1 to 9 of 9

Two independent variables, want function output in matrix form.

  1. #1
    Registered User
    Join Date
    04-14-2012
    Location
    Blacksburg, VA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Two independent variables, want function output in matrix form.

    Hello,

    I'm trying to do a process analysis based on the varying flow rates of two different streams. The first: (20, 30, 40, 50) and the second: (0, 80, 120) - units are the same. I want to set up the analysis so flow rates are the column and row titles of a matrix and the matrix is populated with the calculated costs for each combination.

    I'm running into a wall because I don't want to have to copy the equations through 12 times. Basically, I want to have my inputs be the two vectors and the eventual output be a 3x4 matrix.

    I've been looking through other threads and researching online but am having trouble understanding exactly how to approach this problem in Excel (are arrays an option?); I'm not experienced in Excel programming. VBA suggestions are welcome because I need to learn sometime! lol

    Any solutions or previously solved threads out there?

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Two independent variables, want function output in matrix form.

    I think this can be done without array formulas and macros. But how are costs calculated?
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    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,939

    Re: Two independent variables, want function output in matrix form.

    if you want what i think you want, then the following will maintain its relative row and col references when you copy it across and down your table....

    =D$5*$B6

    it it based on data in col B applied to data in row 5

    Let me know if this is what you need, or maybe upload a sample to show your requirements and results?
    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

  4. #4
    Registered User
    Join Date
    04-14-2012
    Location
    Blacksburg, VA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Two independent variables, want function output in matrix form.

    Costs are calculated through a series of mass and energy balances to determine utility usage (electricity, cooling water, etc). Flow rates also determine the operating hours (thus employee wages) of the plant based on the plant capacity.

    This is why I was looking for a way to avoid repeating the calculation in a new cell for each combination. Does that all make sense?

  5. #5
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Two independent variables, want function output in matrix form.

    Yes it makes sense. I guess we can't provide you with an exact formula, since we don't precisely how it's calculated. But using absolute references ($), as FDibbins suggests, should enable you to write the formula in one cell, and then copy it to the rest of your table.

  6. #6
    Registered User
    Join Date
    04-14-2012
    Location
    Blacksburg, VA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Two independent variables, want function output in matrix form.

    I understand how that would work but wouldn't I have to use absolute references in the same way for each of the other 40 or so calculations to get the final cost sum to work the same way?

    The solution I had in mind more resembled a for loop. I learned to program in Matlab, so with that syntax here's what I was thinking

    [not real code]
    A=(20,30,40,50)
    B=(0,80,120)
    C=zeros(3,4)
    FOR a=1:4
    FOR b=1:3
    ~materials, energy, labor calculations~
    C(b,a)=(sum of costs)
    END
    END
    [/not real code]

  7. #7
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Two independent variables, want function output in matrix form.

    Could you explain how the first cell (A=20, B=0) is calculated and what the answer should be?

  8. #8
    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,939

    Re: Two independent variables, want function output in matrix form.

    the way i wrote that formula, you can copy it across and down, with no "manual" changes needed. it will autmatically adjust to reference the relevant cells. give it a shot and see

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Two independent variables, want function output in matrix form.

    sounds to me like you want a 2 variable data table. check the help for samples but you basically set up the formula in the top left column of the table and the table substitutes the row and column values for each result.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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