From 75ccd6716c47284d3f430aa0705a90751ee5c2c5 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Sat, 10 Dec 2022 22:57:33 +0100
Subject: [PATCH] MAJOR FIX(forces)!: Fix issue in mean force calculation

The previous formatting was taking the mean values of the bounds of the
periods in the force signal, which corresponds essentially to the value
of the maximums. Instead it should return the mean value of the force
OVER THE FULL PERIOD.
---
 utils/calctrueforces.m | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/utils/calctrueforces.m b/utils/calctrueforces.m
index ced4147..9d52b9a 100644
--- a/utils/calctrueforces.m
+++ b/utils/calctrueforces.m
@@ -23,13 +23,14 @@ function [ResData] = calctrueforces(ResData)
                         inF = ResData(i, j).AllPhases(1).(pos).inertiaF;
                         inM = ResData(i, j).AllPhases(1).(pos).inertiaM;
                     else
-                        inF = 0;
-                        inM = 0;
+                        inF = [0, 0, 0];
+                        inM = [0, 0, 0];
                     end
 
                     % Raw force
-                    meanFraw = mean(ResData(i, j).(pos).forces(indexes(iPart, :), :));
-                    meanMraw = mean(ResData(i, j).(pos).moments(indexes(iPart, :), :));
+                    idx = indexes(iPart, 1):indexes(iPart, 2);
+                    meanFraw = mean(ResData(i, j).(pos).forces(idx, :));
+                    meanMraw = mean(ResData(i, j).(pos).moments(idx, :));
 
                     % True value
                     ResData(i, j).AllPhases(1).(pos).meanF(iPart, :) = meanFraw - inF;
-- 
GitLab