Hw3 Gaitanalysis
Hw3 Gaitanalysis
m 1 of 6
figure;
plot(time, foot_length, 'r', 'LineWidth', 1.5, 'DisplayName', 'Foot Length'); hold on;
plot(time, leg_length, 'g', 'LineWidth', 1.5, 'DisplayName', 'Leg Length');
plot(time, thigh_length, 'b', 'LineWidth', 1.5, 'DisplayName', 'Thigh Length');
xlabel('Time (s)');
ylabel('Segment Length (m)');
title('Segment Lengths vs Time');
legend show;
grid on;
% CoM calculations
foot_com = Ankle + foot_com_ratio * (Toe - Ankle);
leg_com = Knee + leg_com_ratio * (Ankle - Knee);
thigh_com = Hip + thigh_com_ratio * (Knee - Hip);
figure;
subplot(2, 1, 2);
plot(time, foot_com(:, 1), 'r', 'DisplayName', 'Foot'); hold on;
plot(time, leg_com(:, 1), 'g', 'DisplayName', 'Leg');
plot(time, thigh_com(:, 1), 'b', 'DisplayName', 'Thigh');
xlabel('Time (s)'); ylabel('Position (in Z)');
title('Center of Mass Position - Z vs Time');
legend show;
2/10/25 10:39 PM C:\Users\jason\OneDriv...\Kevin_Jason.m 2 of 6
subplot(2, 1, 1);
plot(time, foot_com(:, 2), 'r', 'DisplayName', 'Foot'); hold on;
plot(time, leg_com(:, 2), 'g', 'DisplayName', 'Leg');
plot(time, thigh_com(:, 2), 'b', 'DisplayName', 'Thigh');
xlabel('Time (s)'); ylabel('Position (in Y)');
title('Center of Mass Position - Y vs Time');
legend show;
% Normalize angles to 0 360° range as negative range will be difficult for calculation
ankle_angle = mod(ankle_angle, 360);
knee_angle = abs(knee_angle);
knee_angle = mod(knee_angle, 360);
figure;
subplot(2, 1, 1);
plot(time, knee_angle, 'b', 'LineWidth', 1.5, 'DisplayName', 'Knee Angle (\theta_
{21})'); hold on;
xlabel('Time (s)'); ylabel('Angle of Knee (°)');
title('Knee Angle versus Time');
legend show;
ylim([0, 70]); % Set y-axis limits for knee angle
yticks(0:10:70);
grid on;
%% Question 4: Compute Acceleration of CoM of Thigh, Ankle & Knee and Angular
Acceleration for Foot and Leg
2/10/25 10:39 PM C:\Users\jason\OneDriv...\Kevin_Jason.m 3 of 6
for w = 1:length(window_sizes)
win_size = window_sizes(w);
figure;
subplot(3, 1, 1);
plot(time_acc, foot_acc_y_smooth, 'r', 'LineWidth', 1.5, 'DisplayName', 'Foot
Acceleration Y'); hold on;
plot(time_acc, foot_acc_z_smooth, 'b--', 'LineWidth', 1.5, 'DisplayName', 'Foot
Acceleration Z');
xlabel('Time (s)'); ylabel('Acceleration (m/s²)');
title(['Foot CoM Acceleration (Y & Z) - Window Size = ', num2str(win_size)]);
legend show; grid on;
subplot(3, 1, 2);
plot(time_acc, leg_acc_y_smooth, 'r', 'LineWidth', 1.5, 'DisplayName', 'Leg
Acceleration Y'); hold on;
plot(time_acc, leg_acc_z_smooth, 'b--', 'LineWidth', 1.5, 'DisplayName', 'Leg
Acceleration Z');
2/10/25 10:39 PM C:\Users\jason\OneDriv...\Kevin_Jason.m 4 of 6
subplot(3, 1, 3);
plot(time_acc, thigh_acc_y_smooth, 'r', 'LineWidth', 1.5, 'DisplayName', 'Thigh
Acceleration Y'); hold on;
plot(time_acc, thigh_acc_z_smooth, 'b--', 'LineWidth', 1.5, 'DisplayName', 'Thigh
Acceleration Z');
xlabel('Time (s)'); ylabel('Acceleration (m/s²)');
title(['Thigh CoM Acceleration (Y & Z) - Window Size = ', num2str(win_size)]);
legend show; grid on;
end
figure;
subplot(2, 1, 1);
plot(time_angular_acc, foot_angular_acc, 'r', 'LineWidth', 1.5);
xlabel('Time (s)'); ylabel('Foot Angular Acceleration (°/s²)');
title('Foot Angular Acceleration vs Time');
grid on;
subplot(2, 1, 2);
plot(time_angular_acc, leg_angular_acc, 'b', 'LineWidth', 1.5);
xlabel('Time (s)'); ylabel('Leg Angular Acceleration (°/s²)');
title('Leg Angular Acceleration vs Time');
grid on;
%% Question 5: Compute Joint Reaction Forces at Ankle and Knee (Y & Z Directions)
g = 9.81; % Gravity (m/s²)
% Computing Segment Masses from anthropometric table
foot_mass = mass * 0.0145;
leg_mass = mass * 0.0465;
2/10/25 10:39 PM C:\Users\jason\OneDriv...\Kevin_Jason.m 5 of 6
%Compute Joint Reaction Forces at the Ankle and Knee Using Newton’s 2nd Law
R_Ay = foot_mass * foot_acc_y - GRF_y_trimmed + W_foot;
R_Az = foot_mass * foot_acc_z - GRF_z_trimmed + W_foot;
R_Ky = leg_mass * leg_acc_y + R_Ay + W_leg;
R_Kz = leg_mass * leg_acc_z + R_Az + W_leg;
subplot(2, 1, 2);
plot(time(3:end), R_Ky, 'r', 'LineWidth', 1.5, 'DisplayName', 'Knee JRF Y'); hold on;
plot(time(3:end), R_Kz, 'b--', 'LineWidth', 1.5, 'DisplayName', 'Knee JRF Z');
xlabel('Time (s)'); ylabel('Force (N)');
title('Joint Reaction Force at Knee');
legend show; grid on;
figure;
subplot(2, 1, 1);
plot(time(3:end), M_ankle_smooth, 'r', 'LineWidth', 1.5, 'DisplayName', 'Ankle
Moment'); hold on;
xlabel('Time (s)'); ylabel('Moment (Nm)');
title('Joint Reaction Moment at Ankle');
legend show; grid on;
subplot(2, 1, 2);
plot(time(3:end), M_knee_smooth, 'b', 'LineWidth', 1.5, 'DisplayName', 'Knee Moment');
xlabel('Time (s)'); ylabel('Moment (Nm)');
title('Joint Reaction Moment at Knee');
legend show; grid on;
1)
2)
3)
4)
Increasing the window size smooths the acceleration data by reducing noise but also
diminishes finer details and sharp transitions. A moderate window size, such as 5 or 9,
should provide a good balance between noise reduction and the retention of the essential
motion dynamics. When the window size is increased too much, the smoothing effect
becomes excessive, leading to significant loss of important details in the data.
5)
Free Body Diagram
6)
The graph below shows the joint reaction forces at the ankle and knee in the Y and Z
directions as a function of time. The force pattern in both joints is similar: the Y-component
of the force, represented in red, remains almost constant with slight fluctuations, while the
Z-component, in blue, has a marked dip before recovering. That would be a big impact or a
loading phase and would likely relate to a stance or foot-strike event of the movement. The
synchronized knee and ankle JRFs are indicative of integrated joint mechanics and
probably when the person is walking or performing some other dynamic activity.