📄 fm2.m
字号:
% fm2.m% Matlab demonstration script for frequency modulation. The message signal% is m(t)=sinc(100t).echo ont0=.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 vectorkf=100; % deviation constantdf=0.25; % required frequency resolutionm=sinc(100*t); % the message signalint_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 signal[U,u,df1]=fftseq(u,ts,df); % Fourier transform U=U/fs; % scaling[v,phase]=env_phas(u,ts,250); % demodulation, find phase of uphi=unwrap(phase); % restore original phasedem=(1/(2*pi*kf))*(diff(phi)/ts); % demodulator output, differentiate and scale phasepause % Press any key to see a plot of the message and the modulated signalsubplot(2,1,1)plot(t,m(1:length(t)))xlabel('Time')title('The message signal')subplot(2,1,2)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('Magnitude-spectrum of the message signal')subplot(2,1,2)plot(f,abs(fftshift(U))) title('Magnitude-spectrum of the modulated signal')xlabel('Frequency')pause % Pres any key to see plots of the message and the demodulator output with no % noisesubplot(2,1,1)plot(t,m(1:length(t)))xlabel('Time')title('The message signal')subplot(2,1,2)plot(t,dem(1:length(t)))xlabel('Time')title('The demodulated signal')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -