graphics_toolkit("qt") % has "insert text" option
% standardize the dimensions of all 3 plots
set(0, "DefaultAxesXlim",[-2 +2])
set(0, "DefaultAxesYlim",[-1 +1])
dt = .01;
t = -2:dt:2;
carrier = cos(2*pi*3*t);
envelope = e.^(-pi*t.^2);
signal = carrier.*envelope;
figure("position", [1 1 1500 600]);
subplot(1,3,1)
plot(t, signal)
set(gca, 'xtick', -2:2, 'fontsize',16)
xlabel('t', 'fontsize',24, 'fontweight','normal')
ylabel('oscillates at 3 Hz', 'fontsize',18, 'fontweight','normal')
str = 'f(t) = cos(2\pi 3 t) e^{-\pi t^2}';
title(str,'Interpreter','tex', 'fontsize',28, 'fontweight','normal')
mixer = e.^(-i*2*pi*3*t);
mixed = mixer.* signal;
sum(real(mixed))*dt % integrate the product
subplot(1,3,2)
plot(t, real(mixed))
set(gca, 'xtick', -2:2, 'fontsize',16)
xlabel('t', 'fontsize',24, 'fontweight','normal')
ylabel('Integrates to 0.5', 'fontsize',20, 'fontweight','normal')
str = 'Re( f(t) e^{-i2\pi 3 t} )';
title(str,'Interpreter','tex', 'fontsize',28, 'fontweight','normal')
subplot(1,3,3)
plot(t, imag(mixed))
set(gca, 'xtick', -2:2, 'fontsize',16)
xlabel('t', 'fontsize',24, 'fontweight','normal')
ylabel('Integrates to 0.', 'fontsize',20, 'fontweight','normal')
str = 'Im( f(t) e^{-i2\pi 3 t} )';
title(str,'Interpreter','tex', 'fontsize',28, 'fontweight','normal')