MATLAB: How to compare signals’ shape

more than two signals comparisonmotion datasignal comparisonsimilarity of signals

HI! My question is concerning sets of signals acquired by motion system – already normalized to same length. (This is knee flexion and extention during the gait cycle)
I would like to make a program to simply clasiffy signals by its shape. Let'say I have 50 signals and I want the program to find only 5 that behave the same – are alike – represent the gait cycle of patient. I know that this is quite complex since there is more to be considered (time shift, amplitude, etc.). I was thinking some method like kNN, mean square? Any ideas or experiences are welcomed.

Best Answer

If they are all sampled at the same times (so you would have to interpolate them to the same sampling times and not just normalise them for length), the k-th nearest neighbour would be my choice as the simplest classifier.
A simple k-th nearest neighbour classifier is:
ClassVectors = randi(10, 3, 5); % Class Vectors (3x5)
DataVectors = randi(10, 15, 5);
for k1 = 1:size(ClassVectors,1)
for k2 = 1:size(DataVectors,1)
d(k2,k1) = sqrt(sum((ClassVectors(k1,:)-DataVectors(k2,:)).^2));
end
end
[~,ClassMember] = min(d, [], 2);
Then use the sort function to return the five with the lowest distances to your class vector.