Hi,
I am attempting to calculate continuous relative phase (CRP) using the equation: CRP(i) = atan (velocity(i)/displacement(i)). How ever when I run my code the plots do not appear to produce the correct results. From the raw plots of my original data the subject is clearly in antiphase but according to the CRP plot the subject is basically at 0 degrees, in phase, for the entire test period.
I'm fairly certain that it is something basic in my equation but i have checked it several times and cannot seem to figure out what it is.
The code is below, Ignore the first section I just convert the data I have into degrees:
time = data(:,1);
signal_comp = data(:,2);
signal_subj = data(:,3);
% define angle
new_comp = zeros(size(time,1),1);
new_subj = zeros(size(time,1),1);
for row_counter = 1:size(time,1)
new_comp(row_counter) = signal_comp(row_counter)+500;
new_subj(row_counter) = signal_subj(row_counter)+500;
end
angle_comp = zeros(size(time,1),1);
angle_subj = zeros(size(time,1),1);
%convert the data into degrees
for row_counter = 1:size(time,1)
angle_comp(row_counter) = new_comp(row_counter)*0.18;
angle_subj(row_counter) = new_subj(row_counter)*0.18;
end
figure(1)
plot(time, angle_comp), hold on, plot(time, angle_subj, 'r')
angle_velocity_comp = zeros(size(time,1),1);
angle_velocity_subj = zeros(size(time,1),1);
for i = 2:size(angle_subj,1)
angle_velocity_comp(i) = (angle_comp(i)  angle_comp(i1)) / (time(i)  time(i1));
angle_velocity_subj(i) = (angle_subj(i)  angle_subj(i1)) / (time(i)  time(i1));
end
figure(2)
plot(time, angle_velocity_comp), hold on, plot (time, angle_velocity_subj, 'r')
%phase angle
phase_angle_comp = zeros(size(time,1),1);
phase_angle_subj = zeros(size(time,1),1);
for i = 1:size(angle_velocity_comp,1)
phase_angle_comp(i) = atan(angle_velocity_comp(i) / angle_comp(i));
phase_angle_subj(i) = atan(angle_velocity_comp(i) / angle_subj(i));
end
% Continuous Relative Phase (CRP)
CRP = (phase_angle_comp  phase_angle_subj);
figure(3)
plot(time, CRP)
title('CRP')
Thanks in advance,
