Clear Filters
Clear Filters

How to segment an EMG signal according to a column value?

10 views (last 30 days)
I have am EMG dataset, where multiple datas are combined together according to class in a column. Each class represent different muscle activity. Like, class is marked as 1 for hand at rest, where 2 for wrist flexion. I want to segment that data according to class 1 or 2. How to segment this dataset?

Accepted Answer

Image Analyst
Image Analyst on 21 Feb 2024
If your data are in a regular matrix, you can use indexing to extract rows for that class. For example if column 2 contains the class number, you can do
%-------------------------------------------------------------------------------------------
% Get indexes for the rows for the desired class numbers
% Find rows that are marked as class 1.
class1Rows = data(:, 2) == 1;
% Find rows that are marked as class 1.
class2Rows = data(:, 2) == 2;
% Find rows that are marked as EITHER class 1 or class 2.
class1Orclass2Rows = class1Rows | class2Rows;
%-------------------------------------------------------------------------------------------
% Using those indexes, extract the data for the desired class numbers into new variables.
class1 = data(class1Rows, :); % Extract only class 1 rows.
class2 = data(class2Rows, :); % Extract only class 2 rows.
class1OR2 = data(class1Orclass2Rows, :); % Extract if it's EITHER class 1 OR class 2.

More Answers (0)

Categories

Find more on Get Started with 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!