MATLAB: Create subsets by a moving window.

moving window

I have a 1087×12 seismic catalogue and I want to create multiple .txt subsets from it by a 50 events moving window. There will be 1038 .txt files in total.

Best Answer

Anna - assuming that the data from your seismic catalog is in the myData matrix, then you could do the following
fileCount = 1;
for k = 1:length(myData)-50+1
subsetOfData = myData(k:k+50-1,:);
% write subsetOfData to file
filename = sprintf('seismicSubset%03d.txt', fileCount);
writematrix(subsetOfData, filename);
fileCount = fileCount + 1;
end
You'll probably want to come up with a better naming convention for your files (and include where they should be saved to). I haven't tested the above but i think that you get the idea of what can be done.