algorithm to find out combinations of known vectors for resultant vector

2 次查看(过去 30 天)
Hi, i have a lists of vector (actually in complex number) like v1 = [1, 2] v2 = [2, 3] v3 = [1, 1] v4 = [5, 10] ... and i am looking at the resultant vector, says, [8 , 13] any idea what straight forward algorithm I should use to find out the combinations of vectors which can result in [8, 13] in this case?
i understand there will be many possible combinations that i would limit them by scores beforehand.
  7 个评论
Walter Roberson
Walter Roberson 2018-1-12
Are the values complex integers or are they complex floating point that might have fractions?
Omega Wea
Omega Wea 2018-1-12
编辑:Omega Wea 2018-1-12
i think at this stage, just treat them as used/not used and complex integers for now.

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-1-12
Assuming used/not used, this is fairly easy when the size of the set is reasonably small (~ 20 elements max) as you can just try all combinations:
values = [1 + 2i;
2 + 3i;
1 + 1i;
5 + 10i;
1 + 0i;
3 + 3i]; %demo data
target = 8 + 13i;
combs = dec2bin(0:2^numel(values)-1).' - '0';
ishit = sum(values .* combs) == target;
validcombs = logical(combs(:, ishit)) %each column is a valid combination of vector. true says to use that vector
If you'd rather have a list of indices:
validcombs = cellfun(@find, num2cell(validcombs, 1), 'UniformOutput', false)
  7 个评论
Omega Wea
Omega Wea 2018-1-17
great thanks. what would u suggest if the set if large instead? i think the data might grow in future. is it only the process time be longer? or matlab cannot handle more than that?
Guillaume
Guillaume 2018-1-17
The number of combinations is 2^(size of set). Above some size calculating them all will take too much memory/time.
If the set is too big, then you'll have to use a cleverer approach, possibly something out of the optimisation toolbox, with which I'm completely unfamiliar.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by