I have a vector which is [1,1,2,3,5]; I want to loop through all the elements in the vector to check whether the sum of each elements is equal to my input. After that put the corresponfding index of the possible answer as a reference to a new vector which retrun the logic value. For example, if the inout is 6, the corresponding logic value suppose to be [1,0,0,0,1] or anyother combination. The problem is if the value is bigger than 8 it need the sum of 3 elements in vector. How I can get the same answer when the input need three elements add together?

# MATLAB: How to get the corresponding logic value based on the sum of vector elements

arraysort

###### Related Question

- Cell array manipulations in MATLAB
- Can I speed this code up, looking for similarity between two 3-d matrices.
- How to create a vector combinations in pairs
- How do i add all the values which i get using eval function
- How to find all possible combination of a digits between first and last digits
- Select neighbours of a vector efficiently
- Search nx3 array row-wise for 2 equal elements

## Best Answer