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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by