MATLAB: Legend in subplot

legendsubplot

I am plotting my data using subplot. since the legend is a bit long, I want to put a horzontal legend in top of each two sub plots.I can create a legend for each subplot but don't know how to create one at the top of each two plots. I apperciate your help.
x=1:80;
y=rand(15,80);
j=1;
legend={'LC1','LC2','LC3','LC4','LC5','LC6','LC7'};
for ii=1:4
for i=1:4
subplot(2,2,i)
hold on;
row = 0;
row = row+1;
plot(x(j:j+4),y(row,j:j+4))
end
j=j+5;
end

Best Answer

I found another way. First I created a subplot with a legend, then placed the legend on the appropriate place on the plot, I created a M-code from the plot and got the position of the legend, then used the position for all subplots. . . .
end
leg1=legend(legend);
set(leg1,'Position',[p1 p2 p3 p4]);
j=j+5;
end