线性调制程序.doc_第1页
线性调制程序.doc_第2页
线性调制程序.doc_第3页
线性调制程序.doc_第4页
线性调制程序.doc_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

AM解调% am-dem.m% Matlab demonstration script for envelope detection. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise.echo ont0=.15; % signal durationts=0.001; % sampling interval抽样时间fc=250; % carrier frequency载波频率a=0.85; % Modulation indexfs=1/ts; % sampling frequency采样频率t=0:ts:t0; % time vectordf=0.25; % required frequency resolution% message signalm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);c=cos(2*pi*fc.*t); % carrier signalm_n=m/max(abs(m); % normalized message signalM,m,df1=fftseq(m,ts,df); % Fourier transform f=0:df1:df1*(length(m)-1)-fs/2; % frequency vectoru=(1+a*m_n).*c; % modulated signalU,u,df1=fftseq(u,ts,df); % Fourier transform env=env_phas(u); % find the envelope dem1=2*(env-1)/a; % remove dc and rescalesignal_power=spower(u(1:length(t); % power in modulated signalnoise_power=signal_power/100; % noise powernoise_std=sqrt(noise_power); % noise standard deviationnoise=noise_std*randn(1,length(u); % generate noiser=u+noise; % add noise to the modulated signalR,r,df1=fftseq(r,ts,df); % Fourier transform env_r=env_phas(r); % envelope, when noise is presentdem2=2*(env_r-1)/a; % demodulate in the presence of noisepause % Press any key to see a plot of the messagesubplot(2,1,1)plot(t,m(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The message signal)pause % Press any key to see a plot of the modulated signalsubplot(2,1,2)plot(t,u(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The modulated signal)pause % Press a key to see the envelope of the modulated signalclfsubplot(2,1,1)plot(t,u(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The modulated signal)subplot(2,1,2)plot(t,env(1:length(t)xlabel(Time)title(Envelope of the modulated signal)pause % Press a key to compare the message and the demodulated signalclfsubplot(2,1,1)plot(t,m(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The message signal)subplot(2,1,2)plot(t,dem1(1:length(t)xlabel(Time)title(The demodulated signal)pause % Press a key to compare in the presence of noise clfsubplot(2,1,1)plot(t,m(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The message signal)subplot(2,1,2)plot(t,dem2(1:length(t)xlabel(Time)title(The demodulated signal in the presence of noise)双边带解调DSB1% dsb1.m% Matlab demonstration script for DSB-AM modulation. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise.echo ont0=.15; % signal durationts=0.001; % sampling intervalfc=250; % carrier frequencysnr=20; % SNR in dB (logarithmic)fs=1/ts; % sampling frequencydf=0.3; % desired freq. resolutiont=0:ts:t0; % time vectorsnr_lin=10(snr/10); % linear SNR% message signalm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);c=cos(2*pi*fc.*t); % carrier signalu=m.*c; % modulated signalM,m,df1=fftseq(m,ts,df); % Fourier transform M=M/fs; % scaling U,u,df1=fftseq(u,ts,df); % Fourier transform U=U/fs; % scalingC,c,df1=fftseq(c,ts,df); % Fourier transformf=0:df1:df1*(length(m)-1)-fs/2; % freq. vectorsignal_power=spower(u(1:length(t); % power in modulated signalnoise_power=signal_power/snr_lin; % compute noise powernoise_std=sqrt(noise_power); % compute noise standard deviationnoise=noise_std*randn(1,length(u); % generate noiser=u+noise; % add noise to the modulated signalR,r,df1=fftseq(r,ts,df); % spectrum of the signal+noise R=R/fs; % scalingpause % Press a key to show the modulated signal powersignal_powerpause % Press any key to see a plot of the messageclfsubplot(2,2,1)plot(t,m(1:length(t)xlabel(Time)title(The message signal)pause % Press any key to see a plot of the carriersubplot(2,2,2)plot(t,c(1:length(t)xlabel(Time)title(The carrier)pause % Press any key to see a plot of the modulated signalsubplot(2,2,3)plot(t,u(1:length(t)xlabel(Time)title(The modulated signal)pause % Press any key to see a plots of the magnitude of the message and the% modulated signal in the frequency domain.subplot(2,1,1)plot(f,abs(fftshift(M)xlabel(Frequency)title(Spectrum of the message signal)subplot(2,1,2)plot(f,abs(fftshift(U)title(Spectrum of the modulated signal)xlabel(Frequency)pause % Press a key to see a noise samplesubplot(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 subplot(2,1,2)plot(t,r(1:length(t)title(Signal and noise)xlabel(Time)pause % Press a key to see the modulated signal and noise in freq. domainsubplot(2,1,1)plot(f,abs(fftshift(U)title(Signal spectrum)xlabel(Frequency)subplot(2,1,2)plot(f,abs(fftshift(R) title(Signal and noise spectrum)xlabel(Frequency)DSB2% dsb2.m% Matlab demonstration script for DSB-AM modulation. The message signal% is m(t)=sinc(100t). echo on t0=.2;% signal durationts=0.001;% sampling intervalfc=250;% carrier frequencysnr=20;% SNR in dB (logarithmic)fs=1/ts; % sampling frequencydf=0.3; % required freq. resolutiont=-t0/2:ts:t0/2; % time vectorsnr_lin=10(snr/10);% linear SNRm=sinc(100*t); % the message signalc=cos(2*pi*fc.*t);% the carrier signalu=m.*c;% the DSB-AM modulated signalM,m,df1=fftseq(m,ts,df); % Fourier transformM=M/fs; % scalingU,u,df1=fftseq(u,ts,df); % Fourier transformU=U/fs; % scalingf=0:df1:df1*(length(m)-1)-fs/2; % frequency vectorsignal_power=spower(u(1:length(t); % compute modulated signal powernoise_power=signal_power/snr_lin;% compute noise powernoise_std=sqrt(noise_power);% compute noise standard deviationnoise=noise_std*randn(1,length(u); % generate noise sequencer=u+noise;% add noise to the modulated signalR,r,df1=fftseq(r,ts,df); % Fourier transformR=R/fs; % scalingpause % Press a key to show the modulated signal powersignal_powerpause %Press any key to see a plot of the message clfsubplot(2,2,1)plot(t,m(1:length(t)xlabel(Time)title(The message signal) pause % Press any key to see a plot of the carriersubplot(2,2,2)plot(t,c(1:length(t)xlabel(Time)title(The carrier) pause % Press any key to see a plot of the modulated signalsubplot(2,2,3)plot(t,u(1:length(t)xlabel(Time)title(The modulated signal) pause % Press any key to see a plot of the magnitude of the message and the% modulated signal in the frequency domain.subplot(2,1,1)plot(f,abs(fftshift(M)xlabel(Frequency)title(Spectrum of the message signal)subplot(2,1,2)plot(f,abs(fftshift(U)title(Spectrum of the modulated signal)xlabel(Frequency) pause % Press a key to see a noise samplesubplot(2,1,1)plot(t,noise(1:length(t)title(noise sample) xlabel(Time)pause % Press a key to see the modulated signal and noisesubplot(2,1,2)plot(t,r(1:length(t)title(Signal and noise)xlabel(Time)pause % Press a key to see the modulated signal and noise in freq. domainsubplot(2,1,1)plot(f,abs(fftshift(U)title(Signal spectrum)xlabel(Frequency)subplot(2,1,2) plot(f,abs(fftshift(R) title(Signal and noise spectrum)xlabel(Frequency)DSB3% dsb1.m% Matlab demonstration script for DSB-AM modulation. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise.echo ont0=.15; % signal durationts=0.0005; % sampling intervalfc=250; % carrier frequencysnr=10; % SNR in dB (logarithmic)fs=1/ts; % sampling frequencyt_long=20*t0; % extended signal duration n0=floor(t_long/ts)+1; % length of extended signal vector n00=2(ceil(log2(n0);df=fs/n00; % frequency resolutiont_long1=0:ts:t_long; % extended time vectorf=-fs/2+df:df:fs/2; % frequency vector % message signalm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);m_long=m,zeros(1,n0-length(m); % extended message signal c_long=cos(2*pi*fc.*t_long1); % extended carrier signal u_long=m_long.*c_long; % extended modulated signaldu_long=u_long.*c_long;DU=fft(du_long,n00)/fs;M=fft(m_long,n00)/fs; % spectrum of the extended message signal U=fft(u_long,n00)/fs; % spectrum of the extended modulated signal pause % Press any key to see a plots of the magnitude of the message and the% modulated signal in the frequency domain.subplot(2,1,1)plot(f,abs(fftshift(M)xlabel(Frequency)title(Spectrum of the message signal)subplot(2,1,2)plot(f,abs(fftshift(U)title(Spectrum of the modulated signal)xlabel(Frequency) pause % Press a key to see the modulated and modulated X carrier in freq. domainsubplot(2,1,1)plot(f,abs(fftshift(U)title(Modulated signal spectrum)xlabel(Frequency)subplot(2,1,2)plot(f,abs(fftshift(DU) title(Modulated signal X Carrier spectrum)xlabel(Frequency)DSB DEM% dsb_dem.m% Matlab demonstration script for DSB-AM demodulation. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise.echo ont0=.15; % signal durationts=1/1500; % sampling intervalfc=250; % carrier frequencyfs=1/ts; % sampling frequencyt=0:ts:t0; % time vectordf=0.3; % desired frequency resolution% message signalm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);c=cos(2*pi*fc.*t); % carrier signalu=m.*c; % modulated signaly=u.*c; % mixingM,m,df1=fftseq(m,ts,df); % Fourier transform M=M/fs; % scalingU,u,df1=fftseq(u,ts,df); % Fourier transform U=U/fs; % scalingY,y,df1=fftseq(y,ts,df); % Fourier transformY=Y/fs; % scalingf_cutoff=150; % cutoff freq. of the filtern_cutoff=floor(150/df1); % design the filterf=0:df1:df1*(length(y)-1)-fs/2;H=zeros(size(f); H(1:n_cutoff)=2*ones(1,n_cutoff); H(length(f)-n_cutoff+1:length(f)=2*ones(1,n_cutoff);DEM=H.*Y; % spectrum of the filter outputdem=real(ifft(DEM)*fs; % filter outputpause % Press a key to see the effect of mixingclfsubplot(3,1,1)plot(f,fftshift(abs(M)title(Spectrum of the the Message Signal)xlabel(Frequency)subplot(3,1,2)plot(f,fftshift(abs(U)title(Spectrum of the Modulated Signal)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 outputclfsubplot(3,1,1)plot(f,fftshift(abs(Y)title(Spectrum of the Mixer Output)xlabel(Frequency)subplot(3,1,2)plot(f,fftshift(abs(H)title(Lowpass Filter Characteristics)xlabel(Frequency)subplot(3,1,3)plot(f,fftshift(abs(DEM)title(Spectrum of the Demodulator output)xlabel(Frequency)pause % Press a key to compare the spectra of the message an the received signalclfsubplot(2,1,1)plot(f,fftshift(abs(M)title(Spectrum of the Message Signal)xlabel(Frequency)subplot(2,1,2)plot(f,fftshift(abs(DEM)title(Spectrum of the Demodulator Output)xlabel(Frequency)pause % Press a key to see the message and the demodulator output signalssubplot(2,1,1)plot(t,m(1:length(t)title(The Message Signal)xlabel(Time)subplot(2,1,2)plot(t,dem(1:length(t)title(The Demodulator Output)xlabel(Time)FM1% fm1.m% Matlab demonstration script for frequency modulation. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise.echo ont0=.15; % signal durationts=0.0005; % sampling intervalfc=200; % carrier frequencykf=50; % Modulation indexfs=1/ts; % sampling frequencyt=0:ts:t0; % time vectordf=0.25; % required frequency resolution% message signalm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);int_m(1)=0;for i=1:length(t)-1 % Integral of m int_m(i+1)=int_m(i)+m(i)*ts; echo off ;endecho on ;M,m,df1=fftseq(m,ts,df); % Fourier transform M=M/fs; % scalingf=0:df1:df1*(length(m)-1)-fs/2; % frequency vectoru=cos(2*pi*fc*t+2*pi*kf*int_m); % modulated signalU,u,df1=fftseq(u,ts,df); % Fourier transform U=U/fs; % scalingpause % Press any key to see a plot of the message and the modulated signalsubplot(2,1,1)plot(t,m(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The message signal)subplot(2,1,2)plot(t,u(1:length(t)axis(0 0.15 -2.1 2.1)xlabel(Time)title(The modulated signal)pause % Press any key to see a plots of the magnitude of the message and the% modulated signal in the frequency domain.subplot(2,1,1)plot(f,abs(fftshift(M) xlabel(Frequency)title(Magnitude-spectrum of the message signal)subplot(2,1,2)plot(f,abs(fftshift(U) title(Magnitude-spectrum of the modulated signal)xlabel(Frequency)SSB% lssb.m% Matlab demonstration script for LSSB-AM modulation. The message signal% is +1 for 0 t t0/3, -2 for t0/3 t 2t0/3 and zero otherwise. echo on t0=.15; % signal durationts=0.001; % sampling intervalfc=250; % carrier frequencysnr=10; % SNR in dB (logarithmic)fs=1/ts; % sampling frequencydf=0.25; % desired freq. resolutiont=0:ts:t0; % time vectorsnr_lin=10(snr/10); % SNR% the message vectorm=ones(1,t0/(3*ts),-2*ones(1,t0/(3*ts),zeros(1,t0/(3*ts)+1);c=cos(2*pi*fc.*t); % carrier vectorudsb=m.*c; % DSB modulated signalUDSB,udssb,df1=fftseq(udsb,ts,df); % Fourier transformUDSB=UDSB/fs; % scalingf=0:df1:df1*(length(udssb)-1)-fs/2; % frequency vectorn2=ceil(fc/df1); % location of carrier in freq. vector% remove the upper sideband from DSBUDSB(n2:length(UDSB)-n2)=zeros(size(UDSB(n2:length(UDSB)-n2);ULSSB=UDSB; % generate LSSB-AM spectrumM,m,df1=fftseq(m,ts,df); % Fourier transformM=M/fs; % scalingu=real(ifft(ULSSB)*fs; % generate LSSB signal from spectrumsignal_power=spower(udsb(1:length(t)/2; % % compute signal powernoise_power=signal_power/snr_lin; % compute noise powernoise_std=sqrt(noise_power); % compute noise standard deviationnoise=noise_std*randn(1,length(u); % generate noise vectorr=u+noise; % add the signal to noiseR,r,df1=fftseq(r,ts,df); % Fourier transformR=R/fs; % scalingpause % Press a key to show the modulated signal powersignal_powerpause % Press any key to see a plot of the message signalclfsubplot(2,1,1)plot(t,m(1:length(t)axis(0,0.15,-2.1,2.1)xlabel(Time)title(The message signal) pause % Press any key to see a plot of the carriersubplot(2,1,2)plot(t,c(1:length(t) xlabel(Time)title(The carrier) pause % Press any key to see a plot of the modulated signal and its spectrumclfsubplot(2,1,1) plot(0:ts:ts*(length(u)-1)/8,u(1:length(u)/8) xlabel(Time)title(The LSSB-AM modulated s

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论