30 lines
1.1 KiB
Matlab
30 lines
1.1 KiB
Matlab
function plotHarmonicFit(Positions, TrappingPotential, TrapDepthsInKelvin, axis, popt, pcov)
|
|
v = popt(1);
|
|
dv = sqrt(pcov(1,1));
|
|
happrox = harmonic_potential(Positions(axis, :), popt);
|
|
|
|
figure('Position', [100, 100, 1200, 600])
|
|
|
|
subplot(1,2,1)
|
|
title('Fit to Potential')
|
|
plot(Positions(axis, :), happrox, '-r', 'DisplayName', sprintf('\\nu = %.1f \\pm %.2f Hz', v, dv))
|
|
hold on
|
|
plot(Positions(axis, :), TrappingPotential(axis, :), 'ob', 'DisplayName', 'Gaussian Potential')
|
|
xlabel('Distance (\mum)', 'FontSize', 12, 'FontWeight', 'bold')
|
|
ylabel('Trap Potential (\muK)', 'FontSize', 12, 'FontWeight', 'bold')
|
|
ylim([-TrapDepthsInKelvin(1), max(TrappingPotential(axis, :))])
|
|
grid on
|
|
legend('FontSize', 12, 'FontWeight', 'bold')
|
|
|
|
subplot(1,2,2)
|
|
title('Fit Residuals')
|
|
plot(Positions(axis, :), TrappingPotential(axis, :) - happrox, 'ob')
|
|
xlabel('Distance (\mum)', 'FontSize', 12, 'FontWeight', 'bold')
|
|
ylabel('$U_{trap} - U_{Harmonic}$', 'Interpreter', 'latex', 'FontSize', 12, 'FontWeight', 'bold')
|
|
xlim([-10, 10])
|
|
ylim([-1e-2, 1e-2])
|
|
grid on
|
|
tight_layout()
|
|
hold off
|
|
end
|