function [a,b,c,d]=selector(A,B,C,D,xselect,uselect,yselect)

m=length(xselect);
a=zeros(m);
for ii=1:m
    for jj=1:m
        a(ii,jj)=A(xselect(ii),xselect(jj));
    end
end

n=length(uselect);
b=zeros(m,n);
for ii=1:m
    for jj=1:n
        b(ii,jj)=B(xselect(ii),uselect(jj));
    end
end

k=length(yselect);
c=zeros(k,m);
for ii=1:k
    for jj=1:m
        c(ii,jj)=C(yselect(ii),xselect(jj));
    end
end

d=zeros(k,n);
for ii=1:k
    for jj=1:n
        d(ii,jj)=D(yselect(ii),uselect(jj));
    end
end
