Vous êtes sur la page 1sur 4

Ampltude modulation/demodulation:

close all; clear all; fs = 2000; % f = 5; % fc = 250; % N = 2000; % t = (1:N)/fs; % wn = .02; % frequency [b,a] = butter(2,wn); % % Generate AM signal w = (1:N)* 2*pi*fc/fs; % w1 = (1:N)*2*pi*f/fs; % vc = sin(w); % vsig = sawtooth(w1,.5); % vm = (1 + .5 * vsig) .* vc; % Modulation constant = 0.5 subplot(3,1,1); plot(t,vm,'k'); % label,title....... % Add noise with 3.16 times power (10 db) noise = randn(1,N); scale = (var(vsig)/var(noise)) * 3.16; vm = vm + noise * scale; % subplot(3,1,2); plot(t,vm,'k'); % label,title....... % Phase sensitive detection ishift = fix(.125 * fs/fc); % vc = [vc(ishift:N) vc(1:ishift-1)]; % v1 = vc .* vm; % vout = filter(b,a,v1); % subplot(3,1,3); plot(t,vout,'k'); %

Sampling frequency Signal frequency Carrier frequency Use 1 sec of data Time axis for plotting PSD lowpass filter cut - off Design lowpass filter Carrier frequency = 250 Hz Signal frequency = 5 Hz Define carrier Define signal Create modulated signal with a Plot AM Signal....axis, of signal for SNR of -10 db Add noise to modulated signal Plot AM signal..axis, Shift carrier by 1/4 period (45 deg) using periodic shift Multiplier Apply lowpass filter Plot AM Signal

FM &DM: Fs = 8000; % Sampling rate of signal Fc = 3000; % Carrier frequency t = [0:Fs]/Fs; % Sampling times s1 = sin(2*pi*10*t); % Channel 1 %s2 = sin(2*pi*150*t)+2*sin(2*pi*900*t); % Channel 2 %x = [s1]; % Two-channel signal dev = 50; % Frequency deviation in modulated signal y = fmmod(s1,Fc,Fs,dev); % Modulate both channels. z = fmdemod(y,Fc,Fs,dev); % Demodulate both channels. subplot(2,1,1); plot(t,y); title('frequency modulated image');% Plot x on top. subplot(2,1,2); plot(t,z);title('demodulated image');% Plot y below.

DSB-SC: : Write a MATLAB Code (m-file) to generate a DSB-SC and SSB Modulated Signal. Then demodulate these signals to recover the modulated signals from each modulator. Read the following requirements carefully! 1. Use sinusoidal wave as carrier, having frequency as same as your registration number (in kHz). For example, FA09-BET-132 will have to set frequency of 132kHz. 2. Divide the carrier frequency by 10. Use sinusoid of this frequency as message signal. 3. DSB-SC MODEM 3.1. After DSB-SC Modulation, Plot its time domain waveform. 3.2. Also plot the DSB-SC modulated signal in Frequency domain. Note that plot should be well labeled and should depict clear information. Use axis command in code and data cursor in figure for that purpose. Your figures should look like figure 1. 3.3. While filtering the signal, plot the frequency spectrum of the signal to be filtered and the filters frequency response on the same plot using hold on command. Your figure should look like figure 2. 3.4. After Filtering, Plot both the frequency domain and time domain waveforms. Again, plots should be well labeled. Use axis commands and data cursors where require

ANSWER: % task 1 fc=154000; % task 2 fm=fc/10; fs=100*fc; t=0:1/fs:4/fm; xc=cos(2*pi*fc*t); xm=cos(2*pi*fm*t); figure(1) subplot(2,1,1),plot(t,xc); title('carrier signal of 154 khz'); xlabel('time (sec)'); ylabel('amplitude'); subplot(2,1,2),plot(t,xm); title('message signal of 15.4 khz'); xlabel('time (sec)'); ylabel('amplitude'); % DSB-SC MODULATION z1= xm.*xc; figure(2) % task 3.1 subplot(2,1,1),plot(t,z1); title('DSB-SC MODULATION IN TIME DAOMAIN'); xlabel('time (sec)'); ylabel('amplitude'); % task 3.2 l1=length(z1); f=linspace(-fs/2,fs/2,l1); Z1=fftshift(fft(z1,l1)/l1); subplot(2,1,2),plot(f,abs(Z1)); title('DSB SC MODULATION IN FREQUENCY DOMAIN'); xlabel('frequency(hz)'); ylabel('amplitude'); axis([-200000 200000 0 0.3]); % task 3.3 demodulation s1=z1.*xc; S1=fftshift(fft(s1,length(s1))/length(s1)); figure(3) plot(f,abs(S1)); title(' demodulated signal IN FREQUENCY DOMAIN before filtring'); xlabel('frequency(hz)'); ylabel('amplitude'); axis([-200000 200000 0 0.3]); hold on

Hlp=1./sqrt(1+(f./fc).^(2*100)); plot(f,Hlp,'g'); title(' frequency response of low pass filter'); xlabel('frequency(hz)'); ylabel('amplitude'); axis([-200000 200000 0 2]); % task 3.4 E1=Hlp.*S1; figure(4) subplot(2,1,1),plot(f,E1); title(' Recover signal IN FREQUENCY DOMAIN after filtring'); xlabel('frequency(hz)'); ylabel('amplitude'); axis([-200000 200000 0 0.3]); e1=ifft(ifftshift(E1))*length(E1); subplot(2,1,2),plot(t,(1/0.5)*e1); title(' Recover signal IN Time DOMAIN after filtring'); xlabel('time(sec)'); ylabel('amplitude');

Vous aimerez peut-être aussi