06-15-2012 11:04 AM
Hey guys,
Say I have an array of sorted values (of attenuation), I want to generate an array of all possible sums of those values, sort it, then refer to it as a list of all possible attenuation values (lets say theyre bits on a discrete digital attenuator). I will try to show you an example of what I mean with letters:
Array of attens: [a, b, c, d]
I want an array like this: [a+b, a+c, a+d, a+b+c, a+b+d, a+c+d, b+c, b+d, b+c+d]... I hope I'm not missing any combos here...
I'm attaching my attempt at this idea but there's something missing I think, I am doing something wrong...
Thanks for any ideas or help.
Solved! Go to Solution.
06-15-2012 12:32 PM
I wish I had LabVIEW with me. This sounds like a fun problem. I'm thinking this might be a good case for recursion.
06-15-2012 12:37 PM
I actually switched up the vi I'm using to concatenate strings instead of summing integers so I can tell which elements were added.
It's fun to think about for a little while, but Ive been working on this for most of the day and not getting very far... sad.
06-15-2012 01:09 PM
Maybe this will work.
06-15-2012 01:15 PM
The challenge is getting all possible combos.
Have you concidered looking at this as a variation on binary counting?
The total number of combinations is 2^(NumberOfSettings) if you include "None".
So generate a ramp from zero to the total number possible.
Convert each number to a boolean array and then use the boolean to determine if its corresponding value gets add into the total.
After processing all of the values from the ramp the final array should be in ascending order.
I hope that outline helps,
Ben
06-15-2012 01:20 PM
@Ben wrote:
The challenge is getting all possible combos.
Have you concidered looking at this as a variation on binary counting?
The total number of combinations is 2^(NumberOfSettings) if you include "None".
So generate a ramp from zero to the total number possible.
Convert each number to a boolean array and then use the boolean to determine if its corresponding value gets add into the total.
After processing all of the values from the ramp the final array should be in ascending order.
I hope that outline helps,
Ben
Ben, that is actually quite brilliantly simple. I like it.
07-18-2012 01:38 PM - edited 07-18-2012 01:38 PM
So I ran across this again and by remembering Ben's suggestion, threw thi VI together in no time at all... thought I'd upload to save someone else time... and try to give a lil back hopefully haha
thanks again man
-pat