Extracting data points from signals
Show older comments
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
Answers (1)
Frank Meier
on 4 Feb 2021
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.
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!