% coeff = CalcCoeff(oscfit)
%
% Helper function for AnalyzeCoordinates.
% Calculates the oscillation coefficients of a ferrofluid droplet
% in magnetic field based on fitted harmonic oscillator model.
%
% oscfit = fit to oscillation data (t (ms), x (mm))
%
% coeff = Structure containing the oscillation coefficients:
% .k = Magnetic spring constant
% .Fmu = CAH-force
% .beta = Viscous damping coefficient
function coeff = CalcCoeff(oscfit)
m = 1.0069e-05; % Mass of the 10 mul ferrofluid droplet (kg).
T = oscfit.T/1000; % Oscillation period in seconds.
a_0 = oscfit.a_0/1000; % Max peak amplitude in meters.
% You don't have to worry about the following formulas. However, if you
% really want to, there is an article called "Motion of a harmonic
% oscillator with sliding and viscous friction". You can ask the assistant
% about it.
% Magnetic spring constant k:
coeff.k=4*m/(T*T)*(pi*pi+oscfit.g*oscfit.g);
% CAH-force Fmu:
coeff.Fmu=coeff.k*a_0*oscfit.a;
% Viscous damping coefficient beta:
coeff.beta = 2*m*oscfit.g/T;