Create subsets by a moving window.

3 ビュー (過去 30 日間)
Anna Sidiropoulou
Anna Sidiropoulou 2020 年 2 月 27 日
回答済み: Anna Sidiropoulou 2020 年 2 月 27 日
I have a 1087x12 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.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 2 月 27 日
Anna - to be clear, if Data is your 1087x12 matrix, then are you interested in copying the following to file?
Data(1:50,:)
Data(2:51,:)
Data(3:52,:)
...
Data(k:k+50-1,:)
...
Data(1038:1087,:)
Geoff Hayes
Geoff Hayes 2020 年 2 月 27 日
Anna's answer moved here
Yes, I 'm interested.

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 2 月 27 日
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.

その他の回答 (1 件)

Anna Sidiropoulou
Anna Sidiropoulou 2020 年 2 月 27 日
It worked! Although I had to replace 'writematrix' with dlmwrite(filename,subsetOfData) because I have an older Matlab version (2015).
Thank you very much.

カテゴリ

Help Center および File ExchangeSeismology についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by