-
Notifications
You must be signed in to change notification settings - Fork 0
/
phase_cycle_gui.m
43 lines (35 loc) · 1.06 KB
/
phase_cycle_gui.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function phase_cycle_gui(x, sig_x, sig_y)
%PHASE_CYCLE_GUI
%
% Takes x- and y-channels from a lock-in amplifier and cycles them to
% retrieve the in-phase and out-of-phase signals. Cycling is done
% manually through a gui.
%
% SYNTAX:
% [s0, s90, phase_shift] = phase_cycle_gui(sig_x, sig_y)
%
% INPUT:
% sig_x - X-channel from lock-in.
% sig_y - Y-channel from lock-in.
%
import esr_analyses.*
import esr_analyses.utils.*
s0 = @(phi) sig_x * cos(phi) - sig_y * sin(phi);
s90 = @(phi) sig_x * sin(phi) + sig_y * cos(phi);
sig0amp = @(phi) sum(s0(phi).^2);
sig90amp = @(phi) sum(s90(phi).^2);
phi_axis = -pi:2*pi/1000:pi;
phi_axis_deg = phi_axis*180/pi;
s0matrix = s0(phi_axis);
s90matrix = s90(phi_axis);
matrix = s0matrix; matrix(:, :, 2) = s90matrix;
subplot(2, 1, 1)
plot(phi_axis_deg, sig0amp(phi_axis), phi_axis_deg, sig90amp(phi_axis))
legend(["0 deg signal", "90 deg signal"])
axis tight
xlabel('Phase shift [deg]')
xticks(0:45:360)
ylabel('Signal strength')
subplot(2, 1, 2)
slider_plot(x, matrix, 'slider_axis', phi_axis_deg, 'slider_unit', ' deg');
end