function [Uf,Yf,Up,Yp,YL,UL]=mat4oppg13(y,u,L,g,J);
% [Uf,Yf,Up,Yp,YL,UL]=mat4ov13(y,u,L,g,J);
% Purpose:
% Function to make hankel matrices needed to solve Task 13.


[Ny,ny] = size(y);
[Nu,nu] = size(u);

N  = min(Ny,Nu);
K  = N - L - J; 
YL = zeros((L+J+1)*ny,K); UL = zeros((L+J+g)*nu,K);
for i=1:L+J+1
    YL(1+(i-1)*ny:i*ny,:) = y(i:K+i-1,:)';
end
for i=1:L+J+g
    UL(1+(i-1)*nu:i*nu,:) = u(i:K+i-1,:)';
end
% 
%
Up=UL(1:J*nu,:);                     % U_0/J
Uf=UL(J*nu+1:(J+L+g)*nu,:);          % U_J/L+g
Yp=YL(1:J*ny,:);                     % Y_0/J
Yf=YL(J*ny+1:(J+L+1)*ny,:);          % Y_J/L+1
