Find the vector sum combination that gives the minimum vector length
Show older comments
General outline:
I have a number of vectors
,...etc as a pair of numbers such as
,...
I want to list all the possible sums of taking combinations by 2:
where
and
and print their corresponding lengths:
or at least find which sum combination of vectors
gives the minimum length
and the same with combinations by 3, where
and
.
or at least find which sum combination of vectors
. Example:
- For example a combination by 2 let's name it
to keep track of what is added would be
. The length of the vector
, let's call it
will be
. - Or another combination would be the
which gives
, which is smaller than
. - Or if it was a combination by 3 we would have
.
Goal:
I want the program to tell me which combination produces the smallest length and/or to print the list of all the lengths that are possible.
I hope my description is clear! :)
Thank you.
4 Comments
James Tursa
on 23 Mar 2020
Please provide a complete short example with inputs and desired output, not just a text description of what you want.
tandemuse
on 23 Mar 2020
James Tursa
on 23 Mar 2020
I assume duplicates are not allowed? E.g., A+A or A+B+B.
tandemuse
on 23 Mar 2020
Accepted Answer
More Answers (1)
Vineeth Vijayan
on 1 Dec 2020
0 votes
Could you kindly extend help to my problem also?
I have two vectors A = [10 20 22 25; 2 4 5 7; 1 9 11 22] B= [5 6 12 11; 12 11 13 6; 2 12 4 11]
I need to find the min of sum of first coloumn of A. I am allowed to shift elements column wise. Whenever I shift elements in A, corresponding elements in B will also be shifted.
- My constraint is all entries in the first column of B should be same.
Ex. A(:1) = 10 2 1 its sum is 13. But corresponding B is 5 12 2, which is not allowed.
if B = 12 12 12, A(:,1) = 22,2,4 ie. sum is 28
if B = 11 11 11, A(:,1) = 25 4 22 sum is 51.
No other combination satisfy the constraint. Hence the answer is 28.
How can i code this?
SImilarly if one change is allowed in the first coloumn of B, how to find the combinations?
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!