One option would be to test ‘j’ against the number of rows in the matrix-of-interest, something like this:
for j = 1:length(rawData.sub3.epochs.run{i}.movement)
k=ceil(j/4)
m = min(j,size(rawData.sub3.label{i}.data(:,3),1));
then:
if rawData.sub3.label{i}.data(m,3) == 0
↑ ← CHANGE INDEX VARIABLE
and so for the rest of the references to it. That should keep the index from referencing the array elements that do not exist. Other changes to the code as well may be necessary. It might also be worthwhile to consider using break to exit the ‘j’ loop if j>m.
I cannot test this with your data, so I am posting it as UNTESTED CODE.