%% CT Complex Exponential Demo %% Section 1 - Plot CT complex exponental in complex plane vs time % T and k may be changed to plot different signals % Section can be run using short-key Ctrl-Enter % Define time; t_start=0; t_end = 10 ; t_res=0.01; t = t_start:t_res:t_end; % Define period and frequency T=4; w_o = 2*pi/T; 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); % Plot CT-complex exponential figure(1) plot3(t, real(f), imag(f), 'LineWidth',2) hold on plot3(t, real(f), zeros(size(t))-1,'LineWidth',2) plot3(t, zeros(size(t))-1, imag(f),'LineWidth',2) hold off grid on view([135 20]) 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]); %% Section 2 - Plot harmonics superimposed % Plot K number of harmonically related complex exponential of period T T=2; w_o = 2*pi/T; % Define time; t_start=0; t_end = T; t_res=t_end/1000; t = t_start:t_res:t_end; % Define period and frequency K=10;% K denotes the number of harmonics for k=1:K % Define signal f = exp(k*w_o*1i*t); % Plot CT-complex exponential figure(1) plot3(t, real(f), imag(f), 'LineWidth',3) hold on plot3(t, real(f), zeros(size(t))-1) plot3(t, zeros(size(t))-1, imag(f)) grid on % View Imaginary axis only view([0,-1,0]); xlabel('Time', 'Rotation',-30) ylabel('Real Axis', 'Rotation',10) zlabel('Imag Axis'); axis tight; pause; % just to hold one plot end