MATLAB: Apply all steps in whole data set.

loop

clc
clear
ts = xlsread('ECGFiveDays_TRAIN.xlsx');
p=ts(1:1,2:end);
fa = movstd(p ,20,1);
secarray = movstd(fa,20,1) ;
k=maxk(secarray,10);
[~,ii] = min(abs(p(:) – k(:)'));
out = p(unique(ii));
subSequence{1} = p(1:30);
subSequence{2} = p(31:60);
subSequence{3} = p(61:90);
subSequence{4} = p(91:120);
subSequence{5} = p(121:end);
A = [];
for ii = 1:length(subSequence)
if any(ismember(subSequence{ii},out))
A{end+1} = subSequence{ii};
aa = ii;
disp(aa);
end
end
idx=1:length(aa);
bb= subSequence{2};
cc=subSequence{3};
q=[idx bb cc];
xlswrite('Bookecgtest2.xlsx',q,'A1:BI')
Here Iam using only one row(p=ts(1:1,2:end);).I need to apply all these steps (from 3rd step fa = movstd(p ,20,1);) in ts(the full dataset).I try these using for loop then so many errors are coming.How can I apply all these steps in my whole dataset and create an excel sheet.The dataset is attached here.

Best Answer

You need to make up a cell reference with the row and column you want the data to go into. For example
cellReference = sprintf('A%d', row);
xlswrite(fullFileName, data, sheetName, cellReference);
Related Question