Anonymous
Anonymous asked in 電腦與網際網路軟體 · 2 decades ago

# 利用MATLAB模擬頻率解調(FM系統)（２０點）

Rating
• Anonymous

您有John這書就好說明了,給您的程式包含調變及解調,是原書fm2.m這程式,只不過fm2.m給的信號是Sinc function, 但我把其改成fm1.m的原信號,因為sinc function 較不容意看出調變解調失真狀況,而fm1.m類似step function 較好感受失真狀態!! 期望對您有幫助!! 再給您原始fm1.m(只有調變)及fm2.m(含調變及解調)原始程式您就明瞭(這是我一一輸入的程式,也都執行過了!!!,)##要記得兩程式workspace不同,執行fm1後必須關掉matlab或清空workspace後重新執行fm2記得把所附function一一存成.m 檔% jml.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 transformM=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 transformU=U/fs;                                    % scalingpause % Press any key to see 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 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')##############% 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;            % integral of m for i=1:length(t)-1int_m(i+1 )=int_m(i)+m(i)*ts;echo off ;endecho on ;[M,m,df1]=fftseq(m,ts,df);        % Fourier transform% frequency vector% modulated signal% Fourier transform% scaling% demodulation, find phase of u% restore original phase% demodulator output, differentiate and scale phaseM=M/fs;                    % scalingf=[0:df1:df1*(length(m)-1)]-fs/2;u=cos(2*pi*fc*t+2*pi*kf*int_m);[U,u,df1]=fftseq(u,ts,df);U=U/fs;[v,phase]=env_phas(u,ts,250);phi=unwrap(phase);dem=(1/(2*pi*kf))*(diff(phi)/ts);pause % 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 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   % Press 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')若您要一次顯示所有圖片,則將所有pause改成 figure