finding sub sequences of a data set

6 ビュー (過去 30 日間)
Silpa K
Silpa K 2019 年 11 月 8 日
コメント済み: Silpa K 2019 年 11 月 12 日
clc
clear
ts = xlsread('SwedishLeaf_TRAIN.xlsx');
l=length(ts);
for i = 1:500
p=ts(i,:)
for ii = 1:129
subSequence(ii,:) = p((ii-1)*30+ 1:ii*30);
end
I used the above code for finding the subsequences,but it not working.How can I find the subsequence of this.
  4 件のコメント
Star Strider
Star Strider 2019 年 11 月 8 日
You need to describe in detail what your data are, and what you want to do.
Silpa K
Silpa K 2019 年 11 月 8 日
I attached data set.I need to split each row.Each 30 points I need to separate from each row.

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

回答 (1 件)

Ajay Pattassery
Ajay Pattassery 2019 年 11 月 11 日
I assume you want to extract a sub-vector of length 30 from each row. But the total length of the column is 129 which is not divisible by 30. Hence the 5th sub-vector will take 21 elements from the second row and it goes on.
subsequence = (reshape(ts',30,[]))'
If you have a constraint to keep the column length 129 and wish to have sub-parts elements from the same row together, you could split the matrix into two parts. One exactly divisible by 30.
ts1 = ts(:,1:120);
Subsequence1 = (reshape(ts1',30,[]))';
Subsequence2 = ts(:,121:end);
Here Subsequence1 will be 2000x30 and Subsequence2 will have the remaining elements of each row.
  9 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 12 日
buffer() from the signal processing toolbox is useful. But otherwise mat2cell()
L = length(Ts1);
BL = 30;
if mod(L, BL)
Sequences = cell2mat(Ts1, 1, [BL * ones(1, floor(L/BL)), mod(L,BL)]);
else
Sequences = cell2mat(Ts1, 1, BL * ones(1, floor(L/BL)));
end
Silpa K
Silpa K 2019 年 11 月 12 日
I used this in below code,Iam getting errors.Please help me
ts = xlsread('ArrowHead_TRAIN.xlsx');
l=length(ts);
for i = 1:24
p=ts(i,:)
fa = movstd(p,20,1);
secarray=movstd(fa,20,1) ;
k=maxk(secarray,10);
mpt=find(p);
mp=p(mpt(round(numel(mpt)/2)));
G=min(abs(mp-k));
[~,ii] = min(abs(p(:) - k(:)'));
out = p(unique(ii));
L = length(p);
BL = 30;
if mod(L, BL)
Sequences = cell2mat(p, 1, [BL * ones(1, floor(L/BL)), mod(L,BL)]);
else
Sequences = cell2mat(p, 1, BL * ones(1, floor(L/BL)));
end
A = [];
A = [];
for ii = 1:length(SubSequences)
if any(ismember(Subsequences,out))
if (k-mp<=G+l/2)
A{end+1} = Subsequences;
end
end
end
disp(aa);
Z=Subsequences;
idx = p(1:1);
q=[idx Z];
data = q;
cellReference = sprintf('A%d', i);
xlswrite('swetrain.xlsx', data, 1, cellReference);
end

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by