For LOOP for splitting an ECG signal into different CHUNKS

6 ビュー (過去 30 日間)
Ola Ola
Ola Ola 2020 年 2 月 12 日
コメント済み: Ola Ola 2020 年 2 月 12 日
I have an ECG signal `[xx]` with length is 2000, I am trying to create "for loop function" that can split the signal into 10 separate chunks but I am experiencing difficulty. That is, I want to achieve something like this:
yy1 = xx(1:200) -----chunk 1;
yy2 = xx(201:400) ----chunk 2 ;
.
.
.
.
yy10 = xx(1801:2000)-----chunk 10;
A "for loop" will make this faster for me especially with a signal of larger length.
Please, any suggestion on how to do this with a for "loop"?
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 2 月 12 日
Ola - consider using reshape to split the signal into a 200x10 array (assuming exactly 2000 elements in ECG signal).
Jon
Jon 2020 年 2 月 12 日
Sorry Geoff, I was busy writing my answer when you made the above suggestion. As you can see I also went for the reshape approach.

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

採用された回答

Jon
Jon 2020 年 2 月 12 日
編集済み: Jon 2020 年 2 月 12 日
It's not really clear to me from your description what you are trying to do. From what I can infer from your description you have a 2000 by 1 or maybe 1 by 2000 vector of ECG data points and you want to break it up into 10 equal length portions for some type of analysis. I would suggest doing something like this where x is your original length 2000 vector of ECG points and y is the result of some calculation using some function that I will call for the example myFun. You can adapt accordingly to your specific needs
% define dimensions
numPoints = length(x); % 2000 in your case
numSegments = 10; % number of segments
segLength = numPoints/numSegments;
% make a data array that has a column of data for each non-overlapping segment
X = reshape(x,segLength,numSegments)
y = zeros(numSegments,1); % preallocate array to hold results
for k = 1:numSegments
y(k) = myFun(X(:,k))
end
  1 件のコメント
Ola Ola
Ola Ola 2020 年 2 月 12 日
Thank you for the answer.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by