Filipa, use something like
data = [data; zeros(1,30*round(numel(data)/30)-numel(data))]
avdata = mean(reshape(data,numel(data)/30,[]))
The first command adds zeros at the end of the data vector to allow for reshaping the vector into a 30-by-N array. This way you can easily take averages of all N columns.