function lpeq_view(T,fo)
%
% USAGE: lpeq_view(T,fo);
%
% Inputs: T = pause time between plots
% If T is "inf" then you have to hit a key to move to the next plot
% fo = frequency in cycle/sample of a linear phase component
% Must have -0.5 <= fo <= 0.5.
% Use fo = 0 for the case of having no explicit linear phase term
% Use fo not equal to zero to model the case
% where you want to explicitly include a linear phase component in the signal model...
% ... this can be useful when you want to see the effect of a mismatch of
% carrier frequency synchronization in communication signals)
%
% Outputs: Only plots, no matlab variables
%
% Description: Generates a lowpass eq. signal that has a triangular phase and some wiggly sort of
% envelope and then displays its motion around the complex plane.
%
% Also plots the vectors showing the in-phase x_i(n) and the quadrature x_q(n) signals
% The magenta vector = lp eq signal
% The red vector = in-phase signal
% The blue vector = quadrature signal
%
% Also plots the signal's
% envelope and phase functions. As time progresses you see the vector showing the complex signal
% rotating around the complex plane. You also see the red version of the envelope and phase plots
% progressing along the time axis - the blue plots show the whole signal, the red plots show the
% signal's progression up to the current time.
%
% HAVE FUN!!!
%% The steps below create an example of a lowpass equivalent signal
%%% First I create a triangularly varying phase theta(t):
up_down=(pi/4)*[0:10 9:-1:1]/10;
% creates a single triangle going up to pi/4 and down again in 20 samples
temp=(ones(5,1)*up_down).'; % replicates this triangle 5 times (now total of 100 samples)
theta= temp(:).'; % strings the replicas into 100 samples in a row vector
%% Now I have a triangular theta
%% next I create an envelope - I want something that wiggles around a bit and that never goes negative:
%% ... so I first add together some sine waves to get a wiggle and then take the absolute value to get
%% a valid envelope. This is just some Fourier Series trickery using sine waves to build something that wiggles
env=abs(cos(2*pi*0.01*(0:99))+0.5*sin(2*pi*0.05*(0:99))+0.2*sin(2*pi*0.1*(0:99))+0.05*sin(2*pi*0.2*(0:99)));
%% Now I use these two made-up quantities to create a made-up lowpass eq. signal by using the
%% the polar format:
x=env.*exp(j*(2*pi*fo*(0:99) + theta) );
% note: if fo=0 you have a "true" lpeq signal, if not you have something that still MIGHT be thought of as lpeq
%% Now we have a signal... so let's look at it.
% First plot all the vectors in x on the complex plane and then
% delete them, and "hold" the axes.... This just gives me a fixed
% set of polar axes that will be big enough to show the largest vector,
% and the "hold" keeps them there without allowing matlab to adjust their
% size each time I plot to them
subplot(4,2,2)
stem(0:99,env);xlabel('Sample Index');ylabel('Env(n)')
hold on
subplot(4,2,4)
stem(0:99,theta);xlabel('Sample Index');ylabel('\theta(n)')
hold on
subplot(4,2,6)
stem(0:99,real(x));xlabel('Sample Index');ylabel('x_i(n)')
hold on
subplot(4,2,8)
stem(0:99,imag(x));xlabel('Sample Index');ylabel('x_q(n)')
hold on
subplot(2,2,3)
h=compass(x);delete(h);hold on
% compass(x) plots each complex number in x as a vector on the plane
title('magenta = lp eq Signal; red = x_i(n); blue = x_q(n)')
% Now, loop through each element in the lowpass eq. signal x and plot its vector
% on the complex plane using
for n=1:100
subplot(2,2,3)
h1=compass(x(n),'m');set(h1,'linewidth',2); % plot the LP Eq signal vector for sample n
% The "set" command just makes the width of the drawn
% vector bigger so you can see it better
h2=compass(real(x(n)),'r');set(h2,'linewidth',2);
h3=compass(j*imag(x(n)),'b');set(h3,'linewidth',2);
subplot(4,2,2)
stem(n-1,env(n),'r')
subplot(4,2,4)
stem(n-1,theta(n),'r')
subplot(4,2,6)
stem(n-1,real(x(n)),'r')
subplot(4,2,8)
stem(n-1,imag(x(n)),'r')
if isinf(T)
pause % if T is "inf" then pause until user hits key
else
pause(T) % if T is not "inf" use its value to pause for that many seconds
end
delete(h1); % Now delete the plotted vectors so you get an empty set of axes for the next loop
delete(h2);
delete(h3);
end
subplot(4,2,2);hold off
subplot(4,2,4);hold off
subplot(4,2,6);hold off
subplot(4,2,8);hold off
subplot(2,2,3);hold off