about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m')
-rw-r--r--sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m16
1 files changed, 16 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m b/sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m
new file mode 100644
index 00000000..e96d45f8
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/splitLongSeqIntoManyShort.m
@@ -0,0 +1,16 @@
+function short = splitLongSeqIntoManyShort(long, Tsmall)
+% splitLongSeqIntoManyShort Put groups of columns  into a cell array of narrower matrices
+% function short = splitLongSeqIntoManyShort(long, Tsmall)
+%
+% long(:,t)
+% short{i} = long(:,ndx1:ndx2) where each segment (except maybe the last) is of length Tsmall
+
+T = length(long);
+Nsmall = ceil(T/Tsmall);
+short = cell(Nsmall,1);
+
+t = 1;
+for i=1:Nsmall
+  short{i} = long(:,t:min(T,t+Tsmall-1));
+  t = t+Tsmall;
+end