How can I create a matrix that represents all possible "recipes" of 3 chemical components? (i.e., the 3 chemical components must be positive and sum to 100 wt%)
3 views (last 30 days)
Show older comments
Sterling Vanderzee
on 3 Mar 2022
Commented: Davide Masiello
on 8 Mar 2022
Hello! I am trying to create a matrix that represents all possible recipie combinations of 3 chemical components. The 3 chemical components must sum to 100 wt%, and individually have an abundace between 0 and 100 wt% . Eventually I want to create a giant matrix of all possible combinations of 10 chemical components, but I'll start off easy with 3 chemical ingredidents.
I want to create the matrix in small increments of around 0.1 wt%.
The end result I am going for would have 3 columns (one for each ingreident), and each row would contain a recipe (e.g., 10.3 wt% ingredient 1, 70.9 wt% ingredient 2, and 18.8 wt% of inregident 3).
Thanks!
0 Comments
Accepted Answer
Davide Masiello
on 3 Mar 2022
I am going to assume that the percentage of each compound can be rounded to the first decimal digit.
Then I would recommend using the following function:
Given a number n of compunds, the matrix A of all possible recipes is found by
A = allVL1(n,1000)/10;
For n = 3, the first ten rows of the outputs are
A =
0 0 100.0000
0 0.1000 99.9000
0 0.2000 99.8000
0 0.3000 99.7000
0 0.4000 99.6000
0 0.5000 99.5000
0 0.6000 99.4000
0 0.7000 99.3000
0 0.8000 99.2000
0 0.9000 99.1000
...
...
In this case, the size of A is 501501x3, so be careful not to run out of memory when you scale it up to 10 compounds!
8 Comments
Davide Masiello
on 8 Mar 2022
@Sterling Vanderzee I am slightly confused by your terminology.
For instance, when you say the most probable concentration of a specific chemical compund of interest, how is that probability determined?
Are we to understand that there are equations modelling the probability that a certain compound has a certain concentration in your mixture?
If the only constraint is that the sum of all concentrations equals 100, then you are back to the combinatoric problem of all the possible recipes, which is unfeasible for the reasons mentioned above.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!