MATLAB: Regroupe the results in a matrix

matrix

hii i have this
f= 1 0
0 1
0 2
1 3
0 4
1 5
1 6
0 7
this indicate the numbers from 0 to 7 in decimal i want to regroupe the 1 in a matrix and at the same time tell which number it is and do the same thing with 0 i have a mistake somewhere here's the program
N=8;
r=3;
A=zeros(N,r);
Q=zeros(N,1);
for k=0:1:N-1
A(k+1,:)=dec2bin(k,r)-'0';
Q(k+1,1)=xor(xor(A(k+1,1),A(k+1,2)),A(k+1,3));
f=xor(Q,1);
end
for k=0:1:N-1
if f(k+1)==1
se=k
S(k+1,1)=se
else
ss=k
C(k+1,1)=ss
end
end
S =
0
0
0
0
3
5
0
6
C =
0
1
2
0
4
0
0
7
i don't know how to do to delete the 0 i just want 0356 and 1247 to appears
i hope you understand me

Best Answer

Ok, here is my 2nd solution. There's also a faster way to compute f, I think:
f = 1 - (mod(sum(A'), 2) == 1);
x = 0:7;
s = x(~logical(f));
c = x(logical(f));