graphics_toolkit gnuplot
N = 500; %length of plot
sams = 0:N;
cycles = 0.25; % 1/4 cycle of phi(t)
cyc_per_sam = cycles/N;
phi = pi/2 * sin(2*pi*cyc_per_sam*sams);
cycles = 4; % 4 cycles of carrier wave
cyc_per_sam = cycles/N;
z = cos(2*pi*cyc_per_sam*sams + phi); %carrier
x = cos(2*pi*cyc_per_sam*sams).*cos(phi); %in-phase
y = cos(2*pi*cyc_per_sam*sams + pi/2).*sin(phi); %quadrature
figure
plot(sams,sin(phi),'color','red', 'linewidth', 3) %envelope
ylim([-1.2 1.2]);
box off
hold on
plot(sams,cos(phi),'color','blue', 'linewidth', 3) %envelope
plot(sams,x,'color','blue')
plot(sams,y,'color','red')
plot(sams,z,'color','green', 'linewidth', 2)
set(gca, 'xaxislocation', 'origin')
set(gca, 'yaxislocation', 'origin')
set(gca, 'xgrid', 'on');
set(gca, 'ygrid', 'off');
set(gca, 'ytick', [0]);
cycles_per_tick = 0.25;
sam_per_tick = cycles_per_tick/cyc_per_sam;
set(gca, 'xtick', [0:16]*sam_per_tick);
set(gca,'XTickLabel',[' 0'; ' '; '2'; ' '; '4'; ' '; '6'; ' '; '8'; ' '; ' '; '11'; ' '; '13'; ' '; '15'; ' '])
green = [0 170 0]/256;
text(400, .9, '\uparrow sin(\phi(t))', 'color', 'red')
text(30, .86, '\uparrow cos(\phi(t))', 'color', 'blue')
text(147, .44, '\leftarrow I(t)', 'color', 'blue')
text(165, .30, 'Q(t) \rightarrow', 'color', 'red')
text(121, 1, '\leftarrow cos(2\pift + \phi(t)) \rightarrow', 'color', green)
text(146, .87, '= I(t)+Q(t)', 'color', green)
title('In-phase and quadrature components (example)','fontsize', 12);
xlabel('\leftarrow time (t) \rightarrow','fontsize', 12)
ylabel('amplitude','fontsize', 10)