-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalization.m
31 lines (26 loc) · 1.25 KB
/
normalization.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [X, SD] = normalization(start_pos, end_pos, timestep)
%X = normalization(start_pos, end_pos, timestep)
%Calculates (starting) position, velocity, and speed of a submovement
%Inputs: start_pos - starting position, 2 columns, x/y
% end_pos - starting position, 2 columns, x/y
% timestep - time between start and end, in seconds
%Outputs: X - values, 5 columns: start_pos (x,y), velocity (dx, dy), speed
% SD - std. dev., 3 coulumns, start_pos, velocity, speed
vel=(end_pos-start_pos)/timestep;%sec
speed=sqrt(sum(vel.^2,2));
%norm (testData - trainingMean) / trainingStdDev
%X_avg = zeros(1,5);
%pos_SD = std(start_pos);
% X = [start_pos vel speed];
% vel_SD = std(reshape(vel(:,(1:2)),[],1));
% pos_SD = std(reshape(start_pos(:,(1:2)),[],1));
% speed_SD = std(speed(:));
% vel_SD = sqrt(sum(reshape(vel(:,(1:2)),[],1).^2)./numel(vel(:,(1:2)))); %Don't want to substract mean
% pos_SD = sqrt(sum(reshape(start_pos(:,(1:2)),[],1).^2)./numel(start_pos(:,(1:2))));
% speed_SD = sqrt(sum(speed(:).^2)./numel(speed));
vel_SD = mean(sqrt(sum(vel(:,1:2).^2,2)));
pos_SD = mean(sqrt(sum(start_pos(:,1:2).^2,2)));
speed_SD = sqrt(sum(speed(:).^2)./numel(speed));
X = [start_pos/pos_SD vel/vel_SD speed/speed_SD];
SD = [pos_SD, vel_SD, speed_SD];
end