Extracting data points from signals

6 ビュー (過去 30 日間)
Rida Alfonso
Rida Alfonso 2021 年 2 月 4 日
回答済み: Frank Meier 2021 年 2 月 4 日
I have a matrix of size 147456 x 3, This signal represents a data of 72 seconds where the sampling frequency was 2048. The signal is basically a set of 6 repitions (12s each) and the 1st 6 sec, corresponds to activity 1 while the next six seconds corrsponds to activity 2.
Now we want to separate activity 1 and activity 2 into separate matrices.
i have wrote a code but it is not doing the job. Kindly guide me
activity1 = [ ]
for i = 6:6:66
repitition = data(i*fs+1 : (i+6)*fs, :);
activity1 = vertcat(data, repitition)
end

回答 (1 件)

Frank Meier
Frank Meier 2021 年 2 月 4 日
How about this?
%Inputs
sf = 2048;
rep = 6;
time = 72;
%Matrix Init
xRows = sf * time;
xCols = 3;
x = [1:xRows;1:xRows;1:xRows]';
activity1 = zeros(xRows/2,xCols);
activity2 = zeros(xRows/2,xCols);
%Samples per repetition
spr = time*sf/rep;
% Split data
for repIndex = 0:rep-1
for rowIndex = 1: spr /2 % 72/6*2048 /2 = 12288
activity1(repIndex*spr/2+rowIndex , :) = x(rowIndex+repIndex*spr,:);
activity2(repIndex*spr/2+rowIndex , :) = x(rowIndex+ spr/2 + repIndex*spr,:);
end
end
Indices should be checked for valid integers, depends on your pre processing of sample data.

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by