Skip to content

MATLAB Tutorials

Overview

Learn to analyze standardized biomechanical data using MATLAB with our comprehensive tutorial series. These tutorials progress from basic data loading to publication-ready analysis.

Tutorial Series

Loading Data Efficiently

Learn the fundamentals of data loading and memory management - Load phase and time-indexed datasets - Select specific columns to reduce memory usage - Understand data structure and naming conventions - List available subjects, tasks, and variables

Time: 20 minutes | Level: Beginner


Data Filtering

Master the critical skill of data subsetting - Filter by task, subject, and variables - Combine multiple filter conditions - Create reusable filter functions - Save filtered datasets for analysis

Time: 25 minutes | Level: Beginner


Basic Visualization

Create essential biomechanical plots - Compute and plot phase averages - Add standard deviation shading - Create spaghetti plots - Compare multiple conditions

Time: 30 minutes | Level: Intermediate


Cycle Analysis

Analyze individual gait cycles - Extract individual cycles - Calculate ROM and peak values - Detect timing of key events - Identify outlier cycles

Time: 25 minutes | Level: Intermediate


Group Analysis

Aggregate data across subjects - Compute group means and variability - Handle missing data appropriately - Create ensemble averages - Statistical comparisons

Time: 30 minutes | Level: Intermediate


Publication Outputs

Generate publication-ready figures and tables - Create multi-panel figures - Export summary statistics - Format for journal requirements - Ensure reproducibility

Time: 30 minutes | Level: Advanced

Prerequisites

Required Knowledge

  • Basic MATLAB programming
  • Understanding of biomechanical concepts
  • Familiarity with MATLAB plotting and data structures

Required Software

% MATLAB R2019b or later
% Required toolboxes:
% - Statistics and Machine Learning Toolbox (recommended)
% - Signal Processing Toolbox (optional)

% LocoHub library
addpath('user_libs/matlab');

Installation

% Add library to MATLAB path (from project root)
addpath('user_libs/matlab');

% Verify installation
loco = LocomotionData();  % Should work without errors

Learning Path

For Beginners

  1. Start with Tutorial 1 to understand data structure
  2. Master Tutorial 2 on filtering - this is critical
  3. Practice Tutorial 3 visualization techniques
  4. Work through exercises at your own pace

For Experienced Users

  • Jump to specific tutorials as needed
  • Focus on Tutorial 2 (filtering) and Tutorial 3 (visualization)
  • Check Tutorial 6 for publication workflows

For Data Scientists

  • Review Tutorial 1 for data structure
  • Use Tutorial 2 to understand subsetting patterns
  • Apply your own statistical methods to filtered data

Quick Reference

Common Operations

% Add library to path
addpath('user_libs/matlab');

% Load data
loco = LocomotionData('dataset.parquet');

% Filter
levelWalking = loco.filterTask('level_walking').filterSubject('SUB01');

% Get mean patterns
meanPatterns = levelWalking.getMeanPatterns('SUB01', 'level_walking');

% Plot
phase = 0:100/149:100;
plot(phase, rad2deg(meanPatterns.knee_flexion_angle_ipsi_rad));
xlabel('Gait Cycle (%)');
ylabel('Knee Flexion (deg)');
title('Mean Knee Flexion Pattern');
grid on;

Getting Help

Documentation

Community Support

  • GitHub Issues for bug reports
  • Discussions for questions
  • Example scripts in repository

Tips for Success

  1. Always filter first - Don't analyze the entire dataset if you only need a subset
  2. Check your units - Data is stored in radians and SI units
  3. Validate your results - Compare with published normal ranges
  4. Save your work - Use scripts (.m files), not just Command Window
  5. Document your choices - Record filtering criteria and analysis decisions

MATLAB-Specific Tips

  1. Close figures - Use close all to manage memory
  2. Preallocate arrays - For better performance with large datasets
  3. Use cell arrays - For feature names and subject lists
  4. Handle NaN values - Use 'omitnan' option in statistical functions
  5. Export figures - Use print() for high-quality publication figures

Next Steps

Ready to start? Begin with Tutorial 1: Loading Data Efficiently