function y = genYn(filenames, mats)
% read Yields

ukyields = readtable(filenames, 'ReadVariableNames',true);
yindx = [];
for ii = 1:size(mats,1)
    mats_name = ['x' num2str(mats(ii))];
    yindx = [yindx; find(string(ukyields.Properties.VariableNames) == mats_name)];
end
yields = ukyields(:,yindx);

Y = year(ukyields{:,1});
M = month(ukyields{:,1});
id_start = find(100*Y+M == 198301,1);
id_end = find(100*Y+M == 202203,1);

yyyymm = 100*Y(id_start:id_end,1) + M(id_start:id_end,1);
data = table(yyyymm,yields{id_start:id_end,:});
data = splitvars(data);
temp =  ukyields.Properties.VariableNames(yindx);
data.Properties.VariableNames = {'Date',  temp{:}};
y = data;
end




