I would like to write an algorithm which gives an integer, and also an array, as input, and increases some elements. Assume that our array has 4 elements. Indices of selected elements which are going to be increased are as following (left hand integers are our algorithm input and right hand ones are the selected indices):
1 -> 1
2 -> 2
3 -> 3
4 -> 4
5 -> 1,2
6 -> 1,3
7 -> 1,4
8 -> 2,3
9 -> 2,4
10 -> 3,4
11 -> 1,2,3
12 -> 1,2,4
13 -> 1,3,4
14 -> 2,3,4
15 -> 1,2,3,4
Anyone knows how can I implement this algorithm in MATLAB?
I suspect by 'pointers' you mean the arrows of a clock, but that doesn't make it any clearer. What I get from your pattern is that you want the binomial coefficients, you can get them with the nchoosek
function:
array=[1 2 3 4];
for k= 1:numel(array)
b{k,1} = nchoosek(array,k);
end