From what I understood -
jpegFiles = dir('*.jpg');
numfiles = 162;
mydata = cell(1, numfiles);
%Preallocate a table
T = table((1:162)', zeros(162,1), 'VariableNames', {'Serial_No.', 'Average_Luminance_Value'})
for k = 1:numfiles
mydata{k} = imread(jpegFiles(k).name);
RGB = imread(jpegFiles(k).name);
%I = im2gray(RGB);
graying = rgb2gray(RGB);
meanLuminance = mean(graying,"all"); % RGBをグレースケールに変換したときの平均輝度
T{k,2} = meanLuminance;
end