Baseline_correction.m
author: Natalia Martin Sabanés
Date: october 2024
Cite as:  Nicolás-García T, Martín Sabanés N, Bocanegra R, Astumian RD, Perez E, Ibarra B. Transition-path times of molecular shuttles under mechanical equilibrium show symmetry. ChemRxiv. 2024; doi:10.26434/chemrxiv-2024-w3twb

test data: test_trace.dat
1. Inputs: 
 - path and file name of the trace to be analysed. 
 - format type of data: .dat and .txt allowed
 - name: name for the legends and titles of figures
 - order: polynomial order for background baseline.
 
2. Outputs: 
- A .dat trace with background substrated is automatically saved in current folder. 
- Figure 1: Raw trace(black) + polynomial baseline (red)
- Figure 2: Corrected trace, with the background substracted and centered around 0 nm extension.
- Figure 3: raw ocupation distribution (black dots) with fitting function (2- gaussian distribution)
- Figure 4: Occupation distribution centered around 0 nm extension
- Figure 5: DeltaG (energy landscape) recovered by applying Boltzmann method.
- Variable 'summary' in workspace contains: [polynomial order, average force, standard deviation of force, center of gaussian distribution of down station, FWHM of gaussian distribution of down station, error FWHM of gaussian distribution of down station, Max intensity of down station, center of gaussian distribution of top station, FWHM of gaussian distribution of top station, error FWHM of gaussian distribution of top station, Max intensity of top station, distance between centers of gaussians, Occupancy ratio bottom/top]