clc
clear
b=zeros(36,1);
ts = xlsread('ArrowHead_TRAIN.xlsx');
l=length(ts);
for i = 1:36
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));
for i = 1 : size(ts,1)
b = 30;
p = ts(i,:);
n = numel(p);
Z = mat2cell(p, 1, diff([0:b:n-1,n]));
end
A = [];
for ii = 1:length(Z)
if any(ismember(Z{ii},out))
if (k-mp<=G+l/2)
A{end+1} = Z{ii};
aa = ii;
end
end
end
z=Z{ii};
idx=p(1:1);
q=[idx z];
data = q;
cellReference = sprintf('A%d', i);
xlswrite('tra.xlsx', data, 1, cellReference);
end
I used the above code for getting the datasets.How can I write all the needed rows in excel.