% Exercise 9.6 % Program to graph some examples of information signals and the modulated % carriers created by phase modulation and by frequency modulation % Square-wave phase and frequency modulation fc = 4e6 ; Tc = 1/fc ; dt = Tc/32 ; f0 = 2e5 ; T0 = 1/f0 ; w = T0/5 ; N = 2 ; T = N*T0 ; ep = 10*eps ; t = [0:dt:T]' ; for k = 1:N, t = [t ; k*T0-w/2-ep ; k*T0+w/2+ep] ; end t = sort(t) ; I = find(t >= 0 & t <= T) ; t = t(I) ; % Rectwave is a function I wrote to generate rectangular waves % You can generate them your own way x = rectwave(t,T0,0,1/5,0,1) ; % Rectangular wave, period T0, no shift,duty xint = cumtrapz(t,x) ; kp = pi ; cp = sin(2*pi*fc*t + kp*x) ; % Phase modulated result kf = 2*pi*1e6 ; cf = sin(2*pi*fc*t + kf*xint) ; % Frequency modulated result % Exercise 9.16 fc = 1e6 ; Tc = 1/fc ; dt = Tc/32 ; f0 = 5e4 ; T0 = 1/f0 ; N = 1 ; T = N*T0 ; t = [0:dt:T]' ; x = sin(2*pi*f0*t) ; xint = cumtrapz(t,x) ; % cp is the exact phase modulated result and cpa is the narrowband approximation % cf is the exact frequency modulated result and cfa is the narrowband approximation kp = pi/5 ; cp = cos(2*pi*fc*t + kp*x) ; kf = kp*fc/5 ; cf = cos(2*pi*fc*t + kf*xint) ; cpa = cos(2*pi*fc*t) - kp*x.*sin(2*pi*fc*t) ; cfa = cos(2*pi*fc*t) - kf*sin(2*pi*fc*t).*xint ;