MATLAB functions for computing common center of pressure (CoP) metrics from force plate recordings, including:
- CoP Path Length (total)
- Sway Velocity (total; and optional AP/ML components)
- 95% CoP Ellipse Area
- Coefficient of Variation (CV) of CoP displacement (AP/ML/radial)
These scripts are designed for batch processing across many trials stored in a struct array (one element per trial).
Jeevan Jayasuriya
NeuroErgonomics Lab
University of Wisconsin–Madison
-
CoP_PathLength.m
Computes total CoP path length per trial and saves a CSV. -
CoP_SwayVelocity.m
Computes total CoP path length and total sway velocity per trial and saves a CSV. -
CoP_vel_APandML.m
Computes AP, ML, and total path length and sway velocity per trial and saves a CSV and.mat. -
CoP_EllipseArea.m
Computes 95% ellipse area of CoP (AP–ML) per trial and saves a CSV.
Includes optional plotting for a selected range of trials. -
CoP_CoefVatiation.m
Computes CoP coefficient of variation (CV) using absolute displacement:CV_AP = std(|AP|) / mean(|AP|)CV_ML = std(|ML|) / mean(|ML|)CV_R = std(r) / mean(r), wherer = sqrt(AP^2 + ML^2)
Saves a CSV.
All functions expect an input struct array named FFAllStruct (or equivalent), where each element is one trial and contains force plate channels:
Required fields per trial:
Fx,Fy,Fz(forces)Mx,My(moments)
Optional (recommended) metadata fields:
trialID,Subject,Activity,Stimulation,Session,Trial, etc.
The scripts attempt to carry through metadata when writing CSV outputs (when those fields exist).
The scripts compute CoP from forces and moments (in mm), using:
CoP_ML = (-(My + Fx * az0) / Fz) * 1000CoP_AP = ((Mx - Fy * az0) / Fz) * 1000
Where:
az0is the vertical offset (default set to0)- near-zero
Fzvalues are set toNaNto avoid division artifacts
CoP is then centered by subtracting its mean (omitnan) before metric calculation.
Most functions use the following defaults (can be edited inside each file):
- Sampling rate: 1000 Hz
- Low-pass filter: 4th-order Butterworth, cutoff 10 Hz
applyFilter = trueby default
If your force plate sampling rate differs, update samplingRate in each function accordingly.
Each function writes a CSV in the current working directory:
CoP_length.csvCoP_and_Sway_Velocity.csvCoP_and_Sway_Velocity_with_AP_ML.csv(+ also savesCoP_and_Sway_Velocity_with_AP_ML.mat)CoP_ellipse_area.csvCoP_CV Measures.csv
In addition, functions return an updated struct (e.g., FFAllStructWithCoP) with computed fields appended.
- Add this repo to your MATLAB path:
addpath(genpath(pwd));-
Ensure your trial struct array exists in the workspace as
FFAllStruct. -
Run any metric:
FFAllStructWithCoP = calculate_CoP_path_length(FFAllStruct);FFAllStructWithCoP = calculate_CoP_path_length_and_sway_velocity(FFAllStruct);FFAllStructWithCoP = calculate_CoP_path_length_and_sway_velocity(FFAllStruct);Note:
CoP_vel_APandML.mandCoP_SwayVelocity.mdefine the same function name but produce different outputs/files.
Recommendation: keep only one of them in your MATLAB path (or rename one function) to avoid name conflicts.
plotRange = 1:10; % plot trials 1–10 (optional)
FFAllStructWithCoP = calculate_CoP_ellipse_area_with_plot(FFAllStruct, plotRange);CoPstats = calculate_CoP_CV_allinone_abs(FFAllStruct);-
Duplicate function name conflict:
BothCoP_SwayVelocity.mandCoP_vel_APandML.mdefine
calculate_CoP_path_length_and_sway_velocity. MATLAB will call whichever is first on the path.- Fix: rename one function (and file), or remove the one you don’t use.
-
Incorrect sampling rate:
UpdatesamplingRateif your force plate is not 1000 Hz. -
Near-zero vertical force:
The scripts set smallFzvalues toNaN. If your task includes flight phases or unloading, expect gaps.
MIT License (see LICENSE).