filename = 'SOMETHING';
eval(['load ' filename]);
eval(['load ' filename '_vid1'])
vid123=permute(vid,[2 1 3]);
size(vid)
eval(['load ' filename '_vid2'])
vid123(:,:,(size(vid123,3)+1):(size(vid123,3)+size(vid,3)))=permute(vid,[2 1 3]);
size(vid)
I know it has to do with loading a file and finding other files with the same name and '_vidX' appended to it, but what does line 7 exactly do/mean?
Carrying on from Daniel's answer, your question is stemming from the fact that you don't quite know how
permuteworks. The goal ofpermuteis to rearrange the dimensions of a matrix but leave the size of the matrix intact. You specify the matrix you want to "permute" as well as a vector that tells you which input dimensions map to the output.What
permute(vid, [2 1 3]);means is that the second dimension of the input goes to the first dimension of the output. The first dimension of the input goes to the second dimension of the input, and the third dimension stays the same. The effect of this is thatvidis a 3D matrix where each 2D slice /frame is transposed while maintaining the same amount of slices / frames in the final output. You are swapping the second and first dimensions which is essentially what the transpose does.Therefore, the first load statement loads in your frames through the variable
vid, andvid123originally has some number of frames where each frame is transposed - these correspond to the first video. After this, you are loading in the second video wherevidgets overwritten with the frames from the second video. You then add those frames on top ofvid123. Therefore, you are simply piecing the frames from the first frame and second frame together - transposed creating one larger video.I would highly recommend you resave this so that both videos are separated clearly by different variables, or perhaps have a structure that contains both of the videos together. Having the variable
vidbeing stored in two separate files is problematic.Something like this would work:
... or even this would work:
In the first version, both videos are stored in separate variables
vid1andvid2and the second version, both videos are saved in one structure.