The code shown below is what I used to solve my metadata problem. In it I store image capture date only:
load('C:\mypath\workspace.mat')
p = which('G0011363.JPG');
filelist = dir([fileparts(p) filesep '*.JPG']);
fileNames = {filelist.name};
fileNames_size = size(fileNames,2);
number_of_colums = fileNames_size;
for k = 1:number_of_colums
k2 = imfinfo(fileNames{k});
k3 = k2.FileModDate;
imwrite(undistortImage(imread(fileNames{k}), cameraParams2cof, 'OutputView', 'valid'), (strcat(int2str(k), '_R2_3COF.jpg')), 'jpg', 'comment', k3);
end