Download presentation
Presentation is loading. Please wait.
1
GoldExperience 통신공학설계실험 2003440033 Kim Hyun Tai
Kim Jung Woo Kim Dae Hyun
2
triangle함수(1) function x=triangle(tau, T1, T2, fs, df) %
%************************************************* % Generation of triangular pulse % tau : pulse width [sec] % fs : sampling frequency % fs must be greater than or equal to 2/T % [T1, T2] : observation time interval [sec] % df : frequency resolution [Hz] % example % x=rect(2, -5, 5, 10, 0.01) %************************************************** 2
3
triangle함수(2) %clear %tau=2; %T1=-5; T2=5;
%df=0.01; %frequency resolution %fs=10; %sampling frequency ts=1/fs; %sampling period t=[T1:ts:T2]; %observation time interval 3
4
triangle함수(3) % Signal genaration of triangular pulse
x=zeros(size(t)); midpoint=floor((T2-T1)/2/ts)+1; L1=midpoint-fix(tau/2/ts); L2=midpoint+fix(tau/2/ts)-1; x(L1:midpoint)=(2/tau)*t(L1:midpoint)+1; %2/tau is the slope x(midpoint+1:L2)=-(2/tau)*t(midpoint+1:L2)+1; %[X,x1,df1]=fftseq(x,ts,df); %X1=X/fs; %scaling %f=[0:df1:df1*(length(x1)-1)]-fs/2; %frequency vector (range to plot) %plot(t,x); axis([T1, T2 -2 4]) 4
5
DSB_SC (1) % DSB_SC.m % Matlab program example for DSBSC-AM modulation
% The message signal is triangular pulse with pulse width tau=0.1 % clear echo on df=0.3; % desired frequency resolution [Hz] ts=1/1000; % sampling interval [sec] fs=1/ts; % sampling frequency fc=250; % carrier frequency T1=-0.1; T2=0.1; % observation time interval (from T1 to T2 sec) t=[T1:ts:T2]; % observation time vector N = length(t); snr=20; % SNR in dB (logarithmic) snr_lin=10^(snr/10); % linear SNR 5
6
DSB_SC (2) % message signal tau=0.1; % Pulse width [sec]
x=triangle(tau, T1, T2, fs, df); xc=cos(2*pi*fc.*t); % carrier signal xm=x.*xc; % mixing (xm is modulated signal) [X,x,df1]=fft_mod(x,ts,df); % Fourier transform of message signal X=X/fs; % scaling f=[0:df1:df1*(length(x)-1)]-fs/2; %frequency vector (range to plot) [Xm,xm,df1]=fft_mod(xm,ts,df); % Fourier transform of modulated signal Xm=Xm/fs; % scaling [XC,xc,df1]=fft_mod(xc,ts,df); % Fourier transform of carrier signal_power=norm(xm(1:N))^2/N; % power in modulated signal noise_power=signal_power/snr_lin; % compute noise power noise_std=sqrt(noise_power); % compute noise standard deviation noise=noise_std*randn(1,length(xm)); % generate noise 6
7
DSB_SC (3) r=xm+noise; % add noise to the modulated signal
[R,r,df1]=fft_mod(r,ts,df); % spectrum of the signal+noise R=R/fs; % scaling %pause % Press a key to show the modulated signal power signal_power pause % Press any key to see the message signal waveform clf % % Time domain waveforms of message signal and modulated signal subplot(2,1,1) plot(t,xc(1:length(t))) xlabel('Time') title('Carrier waveform') 7
8
DSB_SC (4) subplot(2,1,1) plot(t,x(1:length(t))) xlabel('Time')
title('Message signal') pause % Press any key to see the modulated signal waveform subplot(2,1,2) plot(t,xm(1:length(t))) title('Modulated signal') pause % Press any key to see the spectra % % Frequency domain plots of signal spectral plot(f,abs(fftshift(X))) xlabel('Frequency‘) 8
9
DSB_SC (5) title('Spectrum of the message signal') subplot(2,1,2)
plot(f,abs(fftshift(Xm))) title('Spectrum of the modulated signal') xlabel('Frequency') pause % Press a key to see a noise sample % % Waveform and spectrum of signal plus noise clf subplot(2,1,1) plot(t,noise(1:length(t))) title('noise sample') xlabel('Time') pause % Press a key to see the modulated signal and noise 9
10
DSB_SC (6) plot(t,r(1:length(t))) title('Signal and noise')
xlabel('Time') pause % Press a key to see spectra of modulated signal and noise subplot(2,1,1) plot(f,abs(fftshift(Xm))) title('Signal spectrum') xlabel('Frequency') subplot(2,1,2) plot(f,abs(fftshift(R))) title('Signal and noise spectrum') 10
11
PLOT 결과(1) 그림1 그림2 11
12
PLOT 결과(2) 그림1 그림2 12
13
PLOT 결과(3) 그림1 그림2 13
14
PLOT 결과(4) 그림1 그림2 14
15
PLOT 결과(5) 15
16
DSBSC_DEM (1) % DSBSC_DEM.m
% Matlab program example for DSBSC-AM demodulation % The message signal is triangular pulse with pulse width tau=0.1 clear echo on df=0.3; % desired frequency resolution [Hz] ts=1/1500; % sampling interval [sec] fs=1/ts; % sampling frequency fc=250; % carrier frequency T1=-0.1; T2=0.1; % observation time interval (from T1 to T2 sec) t=[T1:ts:T2]; % observation time vector % % modulation : DSB-SC tau=0.1; % Pulse width [sec] x=triangle(tau, T1, T2, fs, df); % message signal 16
17
DSBSC_DEM (2) %x=rect(tau, T1, T2, fs, df); % message signal
xc=cos(2*pi*fc.*t); % carrier signal xm=x.*xc; % mixing (xm is modulated signal) [X,x,df1]=fft_mod(x,ts,df); % Fourier transform of message signal X=X/fs; % scaling [Xm,xm,df1]=fft_mod(xm,ts,df); % Fourier transform of modulated signal Xm=Xm/fs; % scaling [XC,xc,df1]=fft_mod(xc,ts,df); % Fourier transform of carrier clf f=[0:df1:df1*(length(xm)-1)]-fs/2; %frequency vector (range to plot) subplot(2,1,1) plot(t,x(1:length(t))) %xlabel('Time') title('Message signal') subplot(2,1,2) 17
18
DSBSC_DEM (3) plot(t,xm(1:length(t))) xlabel('Time')
title('Modulated signal') pause % Press any key to see the spectra subplot(2,1,1) plot(f,abs(fftshift(X))) %xlabel('Frequency') title('Spectrum of the message signal') subplot(2,1,2) plot(f,abs(fftshift(Xm))) title('Spectrum of the modulated signal') xlabel('Frequency') % % AWGN noise channel %signal_power=norm(xm(1:N))^2/N; % power in modulated signal %noise_power=signal_power/snr_lin; % compute noise power 18
19
DSBSC_DEM (4) %noise_std=sqrt(noise_power); % compute noise standard deviation %noise=noise_std*randn(1,length(xm)); % generate noise %r=xm+noise; % add noise to the modulated signal r=xm; % received signal (r=rx for distortionless channel) [R,r,df1]=fft_mod(r,ts,df); % spectrum of the received signal R=R/fs; % scaling % % demodulation : coherent detection % We use ideal lowpass filter in this example. y=r.*xc; % mixing [Y,y,df1]=fft_mod(y,ts,df); % Fourier transform of mixer output Y=Y/fs; % scaling f_cutoff=150; % cutoff frequency of the filter n_cutoff=floor(f_cutoff/df1); % design the filter 19
20
DSBSC_DEM (5) H=zeros(size(f));
H(1:n_cutoff)=2*ones(1,n_cutoff); % freq. response of the lowpass filter H(length(f)-n_cutoff+1:length(f))=2*ones(1,n_cutoff); % note that the filter is periodic Z=H.*Y; % spectrum of the filter output z=real(ifft(Z))*fs; % filter output waveform pause % Press a key to see the effect of mixing clf subplot(3,1,1) plot(f,fftshift(abs(X))) title('Spectrum of the the Message Signal') %xlabel('Frequency') subplot(3,1,2) plot(f,fftshift(abs(R))) title('Spectrum of the Received Signal') 20
21
DSBSC_DEM (6) %xlabel('Frequency') subplot(3,1,3)
plot(f,fftshift(abs(Y))) title('Spectrum of the Mixer Output') xlabel('Frequency') pause % Press a key to see the effect of filtering on the mixer output clf subplot(3,1,1) subplot(3,1,2) plot(f,fftshift(abs(H))) title('Lowpass Filter Characteristics') 21
22
DSBSC_DEM (7) plot(f,fftshift(abs(Z)))
title('Spectrum of the Demodulator output') xlabel('Frequency') pause % Press a key to compare the spectra of the message an the received signal clf subplot(2,1,1) plot(f,fftshift(abs(X))) title('Spectrum of the Message Signal') %xlabel('Frequency') subplot(2,1,2) title('Spectrum of the Demodulator Output') pause % Press a key to see the message and the demodulator output signals 22
23
DSBSC_DEM (8) plot(t,x(1:length(t))) title('The Message Signal')
%xlabel('Time') subplot(2,1,2) plot(t,z(1:length(t))) title('The Demodulator Output') xlabel('Time') 23
24
PLOT 결과(1) 그림1 그림2 24
25
PLOT 결과(2) 그림1 그림2 25
26
PLOT 결과(3) 26
27
PLOT 결과(4) 27
28
PLOT 결과(5) 28
29
PLOT 결과(6) 29
30
COMPUTER EXERCISES(2.1) % ce2_1: Computes generalized Fourier series coefficients for exponentially % decaying signal, exp(-t)u(t), or sinewave, sin(2*pi*t) % tau = input(¡¯Enter approximating pulse width: ¡¯); type_wave = input(¡¯Enter waveform type: 1 = decaying exponential; 2 = sinewave ¡¯); if type_wave == 1 t_max = input(¡¯Enter duration of exponential: ¡¯); elseif type_wave == 2 t_max = 1; end clf a = []; t = 0:.01:t_max; cn = tau; n_max = floor(t_max/tau) for n = 1:n_max 30
31
COMPUTER EXERCISES(2.1) LL = (n-1)*tau; UL = n*tau; if type_wave == 1
a(n) = LL, UL); elseif type_wave == 2 a(n) = LL, UL); end disp(¡¯ ¡¯) disp(¡¯c_n¡¯) disp(cn) disp(¡¯Expansion coefficients (approximating pulses not normalized):¡¯) disp(a) x_approx = zeros(size(t)); for n = 1:n_max 31
32
COMPUTER EXERCISES(2.1) x_approx = x_approx + a(n)*phi(t/tau,n-1); end
if type_wave == 1 MSE = 0, t_max) - cn*a*a¡¯; elseif type_wave == 2 MSE = 0, t_max) - cn*a*a¡¯; disp(¡¯Mean-squared error:¡¯) disp(MSE) disp(¡¯ ¡¯) plot(t, x_approx), axis([0 t_max -inf inf]), xlabel(¡¯t¡¯), ylabel(¡¯x(t); x_a_p_p_r_o_x(t)¡¯) hold plot(t, exp(-t)) title([¡¯Approximation of exp(-t) over [0, ¡¯,num2str(t_max),¡¯] with contiguous rectangular pulses of width ¡¯,num2str(tau)]) 32
33
COMPUTER EXERCISES(2.1) elseif type_wave == 2
plot(t, x_approx), axis([0 t_max -inf inf]), xlabel(¡¯t¡¯), ylabel(¡¯x(t); x_a_p_p_r_o_x(t)¡¯) hold plot(t, sin(2*pi*t)) title([¡¯Approximation of sin(2*pi*t) over [0, ¡¯,num2str(t_max),¡¯] with contiguous rectangular pulses of width ¡¯,num2str(tau)]) end % Decaying exponential function for ce_1 % function z = integrand_exp(t) z = exp(-t); % Sine function for ce_1 function z = integrand_sine(t) z = sin(2*pi*t); % Decaying exponential squared function for ce_1 33
34
COMPUTER EXERCISES(2.1) % function z = integrand_exp2(t)
z = exp(-2*t); % Sin^2 function for ce_1 function z = integrand_sine2(t) z = (sin(2*pi*t)).^2; A typical run follows: >> ce2_1 Enter approximating pulse width: 0.125 Enter waveform type: 1 = decaying exponential; 2 = sinewave: 2 n_max = 8 c_n 0.1250 Expansion coefficients (approximating pulses not normalized): 34
35
PLOT 결과 35
36
Goldexperience 감 사 합 니 다 36
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.