HW1 - ylabel('Q component'); figure; subplot(2,1,1)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
clear all; N=20; %number of wave periods Ns=50; %number of samples per period dt=10^-5; %time between samples T=dt*50; %time of the square wave period t=[dt:dt:T*N]; %create the square wave m=zeros(1,N*Ns); for i=1:N m((i-1)*Ns+1:(i-1)*Ns+Ns/2)=1; m((i-1)*Ns+Ns/2+1:(i-1)*Ns+Ns)=-1; end %calculate I and Q parts %calculate magnitude and phase of the complex envelope for i=1:N*Ns I(i)=cos(2*pi/(4*T).*sum(m(1:i))*dt); Q(i)=sin(2*pi/(4*T).*sum(m(1:i))*dt); R(i)=1; Phi(i)=2*pi/(4*T).*sum(m(1:i))*dt; end figure; subplot(2,1,1) plot(t*10^3,I); xlabel('time (milliseconds)') ylabel('I component'); subplot(2,1,2) plot(t*10^3,Q); xlabel('time (milliseconds)')
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ylabel('Q component'); figure; subplot(2,1,1) plot(t*10^3,R); xlabel('time (milliseconds)') ylabel('Magnitude'); subplot(2,1,2) plot(t*10^3,Phi); xlabel('time (milliseconds)') ylabel('Phase'); %calculate the autocorrelation x=R.*exp(sqrt(-1).*Phi); c=conv(x,fliplr(x))/(N*Ns); t=[-T*N+dt:dt:T*N-dt]; figure subplot(2,1,1); plot(t*10^3,real(c)); xlabel('time (milliseconds)'); ylabel('Autocorrelation'); %estimate the PSD [S,f]=Psd(x,dt); subplot(2,1,2); plot(f/1000,10*log10(S)); axis([-10 10 -100 0]); xlabel('Frequency (kHz)') ylabel('PSD (dB)');...
View Full Document

Ask a homework question - tutors are online