필터 지우기
필터 지우기

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