%% DT Complex Exponential Demo
%% Section 1 - Plot DT complex exponental in complex plane vs time
% N and k may be changed to plot different signals
% Plot 2 periods
% Section can be run using short-key Ctrl-Enter

% Define time;
N=4;
t_start=0;
t_end = 2*N;
t_res=1;
t = t_start:t_res:t_end; 
t_ct = t_start:0.01:t_end; % contonuous time for plot of underlying complex exponential
% Define period and frequency
w_o = 2*pi/N;
k=1; % you can choose k to be any integer and this will generate k-th harmonic of frequency k*w_0

% Define signal
f = exp(k*w_o*1i*t); % dt-signal
f_ct = exp(k*w_o*1i*t_ct); % ct-signal
% Plot CT-complex exponential
figure(1)
plot3(t_ct, real(f_ct), imag(f_ct), 'LineWidth',3);
hold on
plot3(t_ct, real(f_ct), zeros(size(t_ct))-1, 'LineWidth',3)
plot3(t_ct, zeros(size(t_ct))-1, imag(f_ct), 'LineWidth',3)
% plot DT complex exponential
stem3(t, real(f), imag(f), 'LineWidth',3);
hold on
stem3(t, real(f), zeros(size(t))-1)
stem3(t, zeros(size(t))-1, imag(f))
hold off
grid on
view([-125  30])
xlabel('Time', 'Rotation',-30)
ylabel('Real Axis', 'Rotation',10)
zlabel('Imag Axis');
axis tight;

%% Change View - uncomment the desired line

% View Real axis only
%view([0,0,1])

% View Imaginary axis only
%view([0,-1,0]);

% View Complex Plane
%view([1,0,0]);
