LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Additive combinations of an array, no value used twice

Solved!
Go to solution

Wanting to solve for an array holding these numeric values: 0.05, 0.1, 0.22, 0.45, 1.0, 2.2, and 4.4. All possible additive combinations thereof, each value used only once. Results such as, 0.05, 0.1, 0.15 ... and so forth. A result might be 0.45 but never 0.44, the latter resulting from 0.22 added to itself. Like that...

 

Said values are in mH (mili-Henries) representing toroid inductors in a relay-switched bank. Said bank being part of an automatic antenna tuner. I'm wanting to validate an antenna of my own design against a transceiver's capacity to null out its standing wave ratio it at various frequencies. An amateur radio project, which I shall publish in the public domain. 

0 Kudos
Message 1 of 9
(327 Views)
Solution
Accepted by KY8D

Very quick and dirty, chock full of coercion dots, and I'm not very well caffeinated yet, but I think this works and is mathematically sound:

 

Additive combinations.png

Message 2 of 9
(309 Views)

...
All possible additive combinations thereof, each value used only once.

That doesn't make any sense.

0 Kudos
Message 3 of 9
(299 Views)

@BertMcMahan wrote:

Very quick and dirty, chock full of coercion dots, and I'm not very well caffeinated yet, but I think this works and is mathematically sound:


 

I had basically the same idea (count up to all possible 7 bit numbers (one bit for each value) and sum the ones where the bit=1.

 

You might want to sort the resulting array by the sum so it is easy to find the setting closest to the desired value.

0 Kudos
Message 4 of 9
(294 Views)

After building the initial array at top left, and before the display "Number of Combinations", which VI is that, please? The image is slightly fuzzy, and I fail to recognize that VI.

0 Kudos
Message 5 of 9
(287 Views)

Each value represents a physical component (a toroid inductor), switched in or out by a relay. No inductor may be used twice at same time. It is as if you have the values written down on pieces of paper. Then arrange them in combinations of one or more, adding the sum. No piece of paper can exist in two places at once. The same with a switched bank of physical components.

0 Kudos
Message 6 of 9
(280 Views)

That's "Power of 2".

 

Also, that image is a VI Snippet, and you can drag it into LabVIEW without needing to recreate it:

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x2PkCAI&l=en-US

 

0 Kudos
Message 7 of 9
(271 Views)

Here's my attempt. The boolens tell which elements to enable for the given sum.

 

altenbach_0-1727710876320.png

 

 

Message 8 of 9
(268 Views)

Yes! Thank you so much!

0 Kudos
Message 9 of 9
(248 Views)