Matrix returns wrong values

Margooox

New Member
Joined
Jul 19, 2021
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Hello everyone!

I'm trying to create exponential damage curves for a set of materials by basing myself off of this data:

Damage amount (Y axis)0255075100
Light Leather30.021.015.07.53.0
Heavy Leather40.032.020.012.06.0
Steel50.042.535.020.012.5
Carbon Steel50.045.042.532.517.5
Hardened Steel40.038.034.020.012.0
Ceramics40.032.020.016.04.0
Polyethylene20.019.017.06.02.0
Titanium70.066.563.056.042.0
Kevlar70.069.366.552.542.0
Aramid70.063.059.549.035.0
Boron Carbide60.045.030.027.024.0
Iron30.025.518.012.04.5

I then use this formula to create a matrix that would show me the results from all points in the curve (from 0 to 100):
Excel Formula:
=BYCOL(TRANSPOSE(H3:H14),LAMBDA(X,let(n,SEQUENCE(101,1,0,1),list,filter(I3:M,H3:H=x),{X;GROWTH(list,I2:M2,N6:N106)})))

H3:H14 being the range of the material list (leather, steel etc...), I2:M being my amount of damage (Y axis), I3:M14 being my X axis.

This then generates the following matrix:
Light LeatherHeavy LeatherSteelCarbon SteelHardened SteelCeramicsPolyethyleneTitaniumKevlarAramidBoron CarbideIron
0.035.946.557.657.248.350.530.174.476.474.655.937.1
1.035.145.756.856.747.749.429.474.076.074.155.436.4
2.034.344.856.056.147.148.428.773.775.673.754.935.8
3.033.544.055.255.646.547.428.173.375.273.254.435.1
4.032.843.154.455.146.046.427.473.074.972.753.934.5
5.032.142.353.654.545.445.426.872.674.572.253.433.9
6.031.341.552.954.044.944.426.272.374.171.752.933.3
7.030.740.752.253.544.343.525.671.973.771.352.432.7
8.030.039.951.453.043.842.625.071.673.370.851.932.1
9.029.339.250.752.543.241.724.471.272.970.451.431.5
10.028.638.550.052.042.740.823.970.972.669.950.930.9
11.028.037.749.351.542.240.023.370.672.269.450.430.4
12.027.437.048.651.041.739.122.870.271.869.050.029.8
13.026.836.347.950.541.238.322.369.971.468.549.529.3
14.026.235.647.350.040.737.521.869.671.168.149.028.8
15.025.634.946.649.540.236.721.369.270.767.648.628.2
16.025.034.345.949.039.736.020.868.970.367.248.127.7
17.024.533.645.348.539.235.220.368.670.066.847.727.2
18.023.933.044.748.138.734.519.968.269.666.347.226.7
19.023.432.444.047.638.333.719.467.969.265.946.826.3
20.022.931.843.447.237.833.019.067.668.965.546.425.8
21.022.431.242.846.737.432.318.567.368.565.045.925.3
22.021.930.642.246.236.931.718.167.068.264.645.524.9
23.021.430.041.645.836.531.017.766.667.864.245.124.4
24.020.929.441.045.436.030.417.366.367.563.844.724.0
25.020.428.940.544.935.629.716.966.067.163.444.223.5
26.020.028.339.944.535.129.116.565.766.862.943.823.1
27.019.527.839.344.134.728.516.165.466.462.543.422.7
28.019.127.338.843.634.327.915.865.166.162.143.022.3
29.018.726.738.243.233.927.315.464.865.761.742.621.9
30.018.326.237.742.833.526.715.164.465.461.342.221.5
31.017.825.737.242.433.126.214.764.165.160.941.821.1
32.017.425.336.742.032.725.614.463.864.760.541.420.7
33.017.124.836.141.632.325.114.163.564.460.141.020.4
34.016.724.335.641.231.924.613.763.264.159.740.720.0
35.016.323.935.140.831.524.013.462.963.759.340.319.6
36.015.923.434.640.431.123.513.162.663.458.939.919.3
37.015.623.034.240.030.723.012.862.363.158.639.518.9
38.015.222.533.739.630.422.612.562.062.758.239.218.6
39.014.922.133.239.230.022.112.261.762.457.838.818.2
40.014.621.732.738.829.621.612.061.462.157.438.417.9
41.014.221.332.338.529.321.211.761.261.857.038.117.6
42.013.920.931.838.128.920.711.460.961.456.737.717.3
43.013.620.531.437.728.620.311.260.661.156.337.417.0
44.013.320.130.937.428.219.910.960.360.855.937.016.7
45.013.019.730.537.027.919.410.760.060.555.636.716.4
46.012.719.330.136.627.519.010.459.760.255.236.316.1
47.012.419.029.736.327.218.610.259.459.954.936.015.8
48.012.218.629.235.926.918.310.059.159.654.535.715.5
49.011.918.328.835.626.517.99.758.959.254.135.315.2
50.011.617.928.435.226.217.59.558.658.953.835.014.9
51.011.417.628.034.925.917.19.358.358.653.434.714.7
52.011.117.227.634.625.616.89.158.058.353.134.314.4
53.010.916.927.334.225.316.48.957.758.052.734.014.1
54.010.616.626.933.925.016.18.757.557.752.433.713.9
55.010.416.326.533.624.715.78.557.257.452.033.413.6
56.010.216.026.133.324.415.48.356.957.151.733.113.4
57.09.915.725.832.924.115.18.156.756.851.432.813.2
58.09.715.425.432.623.814.87.956.456.551.032.512.9
59.09.515.125.032.323.514.57.756.156.250.732.212.7
60.09.314.824.732.023.214.27.555.856.050.431.912.5
61.09.114.524.331.722.913.97.455.655.750.031.612.2
62.08.914.224.031.422.713.67.255.355.449.731.312.0
63.08.714.023.731.122.413.37.055.155.149.431.011.8
64.08.513.723.330.822.113.06.954.854.849.130.711.6
65.08.313.423.030.521.812.76.754.554.548.730.411.4
66.08.113.222.730.221.612.56.654.354.248.430.111.2
67.07.912.922.429.921.312.26.454.054.048.129.811.0
68.07.812.722.129.621.111.96.353.853.747.829.610.8
69.07.612.521.829.320.811.76.153.553.447.529.310.6
70.07.412.221.429.020.511.46.053.253.147.229.010.4
71.07.212.021.128.720.311.25.953.052.846.928.710.2
72.07.111.820.828.520.111.05.752.752.646.628.510.0
73.06.911.520.628.219.810.75.652.552.346.328.29.8
74.06.811.320.327.919.610.55.552.252.046.027.99.7
75.06.611.120.027.719.310.35.352.051.845.727.79.5
76.06.510.919.727.419.110.15.251.751.545.427.49.3
77.06.310.719.427.118.99.95.151.551.245.127.29.1
78.06.210.519.226.918.69.75.051.251.044.826.99.0
79.06.010.318.926.618.49.54.951.050.744.526.78.8
80.05.910.118.626.318.29.34.850.850.444.226.48.7
81.05.89.918.426.118.09.14.750.550.243.926.28.5
82.05.79.718.125.817.78.94.550.349.943.625.98.3
83.05.59.517.925.617.58.74.450.049.743.325.78.2
84.05.49.417.625.317.38.54.349.849.443.025.48.0
85.05.39.217.425.117.18.34.249.649.142.825.27.9
86.05.29.017.124.916.98.24.149.348.942.525.07.8
87.05.18.816.924.616.78.04.149.148.642.224.77.6
88.04.98.716.624.416.57.84.048.948.441.924.57.5
89.04.88.516.424.116.37.73.948.648.141.724.37.3
90.04.78.316.223.916.17.53.848.447.941.424.17.2
91.04.68.215.923.715.97.33.748.247.641.123.87.1
92.04.58.015.723.515.77.23.647.947.440.823.67.0
93.04.47.915.523.215.57.03.547.747.140.623.46.8
94.04.37.715.323.015.36.93.447.546.940.323.26.7
95.04.27.615.122.815.16.73.447.346.640.123.06.6
96.04.17.414.922.615.06.63.347.046.439.822.76.5
97.04.07.314.722.314.86.53.246.846.239.522.56.4
98.03.97.214.422.114.66.33.146.645.939.322.36.2
99.03.97.014.221.914.46.23.146.445.739.022.16.1
100.03.86.914.021.714.26.13.046.145.538.821.96.0

The results are all off by a little bit, Light Leather's 0 X should be 30 but in the matrix it is returned as 35.9. All the results are off in a similar way and I can't figure out why.
Any help would be highly appreciated!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
paste into a module,
here your matrix page is called: 'matrix'. change: Sheets("matrix").Activate ,as needed
then run: CreateMatrixNums

Code:
Private mcolQty As Collection, mcolMat As Collection

Sub CreateMatrixNums()
Dim i As Integer, j As Integer, k As Integer, m As Integer, v As Integer, x As Integer
Dim nMin As Single, nMax As Single
Dim sQty As String, sMat As String, sVal As String
Dim vList
Dim ary()

Sheets("matrix").Activate

  '=======collect qtys
Set mcolQty = New Collection
Range("B1").Select
While ActiveCell.Value <> ""
     sQty = ActiveCell.Value
     mcolQty.Add sQty, sQty
     
     ActiveCell.Offset(0, 1).Select      'next col
Wend


  '===========collect materials
Set mcolMat = New Collection

Range("A2").Select
While ActiveCell.Value <> ""
     sMat = ActiveCell.Value
     mcolMat.Add sMat, sMat
     
       'back to start cell

     ActiveCell.Offset(1, 0).Select      'next row
Wend

 'build value array
ReDim ary(mcolMat.Count, mcolQty.Count)

Dim c As Integer, r As Integer
r = 1
 'load array w mat values
Range("A2").Select
While ActiveCell.Value <> ""
     sVal = ""
     For c = 0 To mcolQty.Count
        sVal = ActiveCell.Offset(0, c).Value
        ary(r, c) = sVal
     Next
     
     r = r + 1
     ActiveCell.Offset(1, 0).Select      'next row
Wend


  '======post headers
Sheets.Add
For i = 1 To mcolMat.Count
   Range("B1").Offset(0, i - 1).Value = mcolMat(i)
Next


  '=======post values 1 thru N
Range("A2").Select
For i = 1 To mcolQty.Count
  If mcolQty(i) = 0 Then
     nMin = 0
  Else
     nMin = mcolQty(i) + 1
  End If
  
  If i = mcolQty.Count Then
    nMax = mcolQty(i)
  Else
    nMax = mcolQty(i + 1)
  End If
    'change over to new min/max
  If nMin > 0 Then nMin = nMin - 1
   
     '======post 1Mat , N values
  For x = nMin To nMax
     Cells(ActiveCell.Row, 1).Select
     ActiveCell.Value = x
     
     If x = nMax Then  'dont post max
       Beep
     Else
        For m = 1 To mcolMat.Count
           ActiveCell.Offset(0, m).Value = ary(m, i)
        Next
        ActiveCell.Offset(1, 0).Select      'next col
     End If
  Next
Next


'=====last line
   For m = 1 To mcolMat.Count
     For i = 1 To mcolQty.Count
       ActiveCell.Offset(0, m).Value = ary(m, i)
     Next
   Next
   ActiveCell.Offset(1, 0).Select      'next col

Set mcolQty = Nothing
Set mcolMat = Nothing
MsgBox "done"
End Sub
 
Upvote 0
I then use this formula ...
Excel Formula:
=BYCOL(TRANSPOSE(H3:H14),LAMBDA(X,let(n,SEQUENCE(101,1,0,1),list,filter(I3:M,H3:H=x),{X;GROWTH(list,I2:M2,N6:N106)})))
Are you sure that is your formula? It doesn't look like a valid formula to me
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top