One error I have need notiching that, at the initial loop, you consider "pic" as single variable. However, in the 2nd loop, it is called as as cell array, it might be-
for im=1:size(files)
.....
pic{im}= imread(fdir);
end
A lot of similar question answers are available in MATLAB Answers (call sequence of images), and the later part converts them into frames using the im2frame function.