Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

As value of a decrease , M is computed in for loop and G2 is generated having rows equal to M, than i want to copy G1 rows portion equal to size of M to G2 in each iteration of for loop from maximum row to minimum,

1 view (last 30 days)
G1 = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1;
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1;
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1;
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1;
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1;
0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1;
0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1;
0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1;
0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1;
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1];
m=4;
r=4;
k=0;
n=2^m;
for i=1:r
k= k+factorial(m)/(factorial(m-i)*factorial(i));
end
for a=r:-1:2
M=factorial(m)/(factorial(m-a)*factorial(a));
G2 = zeros(M,n);
for o=M:1:1
G2(o,:) = G1(k,:);
k=k-1;
end
end

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!