Apply all steps in whole data set.

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.

1 件のコメント

Silpa K
Silpa K 2019 年 10 月 12 日
if I use
ts = xlsread('ECGFiveDays_TRAIN.xlsx');
for i=1:23
p=ts(i,:)
fa = movstd(p,20,1);
secarray=movstd(fa,20,1)
k=maxk(secarray,10)
%figure(1)
%plot(p)
[~,ii] = min(abs(p(:) - k(:)'));
out = p(unique(ii));
%figure(2)
%plot(p)
%hold on;
%plot(cell2mat(arrayfun(@(x)find(abs(p-x)<eps),out, 'UniformOutput',false)), out,'*');
for iii=1:24
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);
end
A = [];
for ii = 1:length(subSequence)
if any(ismember(subSequence{ii},out))
A{end+1} = subSequence{ii};
aa = ii;
disp(aa);
end
end
end
Then how can I write all the subsequence into excel sheet .(that is write the subsequences contain in 1st row and next write the subsequences contain in the 2nd row in the 2nd row of excel).

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

 採用された回答

Image Analyst
Image Analyst 2019 年 10 月 12 日

0 投票

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);

4 件のコメント

Silpa K
Silpa K 2019 年 10 月 12 日
Using the above program I will get the subsequences from each row.I need to write the all subsequnces.From the above syntax how can I put those subsequences one after the other.In the excel's 1st row I need to write the subsequences that from 1st row in the dataset.Like that all the subsequences want to write.
Image Analyst
Image Analyst 2019 年 10 月 12 日
You could have a loop over rows, where you increment the row
for row = 1 : totalRows
% Get data for this row
data = .... whatever .....
cellReference = sprintf('A%d', row);
xlswrite(fullFileName, data, sheetName, cellReference);
end
Silpa K
Silpa K 2019 年 10 月 12 日
Thank you sir,
This is getting.But Iam getting same value in every row.In the code I was given above there are different subsequences for every row.I need to write the different subsequences.What can I do,please help me.
Silpa K
Silpa K 2019 年 10 月 12 日
Sorry.Its my mistake I got the excelsheet.Thank you.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

タグ

質問済み:

2019 年 10 月 12 日

コメント済み:

2019 年 10 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by