Hi,
I have k element vector with elements {1,-1,0}.
I need to generate 3 power k combinations.
How can i generate in matlab?
Can someone suggest me logic to get it?
Thnx for the reply.
I have a k=3 element vector {1,-1,0}
And have n nodes which can transmit any of the three elements.
I need to generate all 3^n combinations i.e with repetition allowed for the elements.
I got the code in MATLAB as v = [1 -1 0];
n=8;
k = length(v);
m = zeros(k^n,n);
c = repmat(v( : ),k^(n-1),1);
for col = 1:int
t = reshape(c,k^col,length(c)/(k^col));
t = t';
m,col) = t( : );
end but i need to generate in C.
Can someone suggest me logic or algorithm to generate all the combinations in C