AM的调制与相干解调
%四个函数放在同一路径下即可
function am_xianggan() close all; clear all; dt=0.001; fm=1; fc=10; T=5; t=0:dt:T;
mt=sqrt(2)*cos(2*pi*fm*t); A=2;
s_am=(A+mt).*cos(2*pi*fc*t); figure(1); subplot(311);
plot(t,s_am);hold on; plot(t,A+mt,'r--');
title('AMμ÷??D?o??°??°ü??'); xlabel('t');
rt=s_am.*cos(2*pi*fc*t); rt=rt-mean(rt); [f,rf]=T2F(t,rt); [t,rt]=lpf(f,rf,2*fm); subplot(312); plot(t,rt);hold on; plot(t,mt/2,'r--');
title('?à?é?aμ÷oóD?o?2¨D?ó?ê?è?D?o?μ?±è??'); xlabel('t'); subplot(313); [f,sf]=T2F(t,s_am); psf=(abs(sf).^2)/T; plot(f,psf);
axis([-2*fc 2*fc 0 max(psf)]); title('AMD?o?1|?ê?×'); xlabel('f');
function [t st]=F2T(f,sf)
%This function calculate the time signal using ifft function for the input %signal's spectrum
df = f(2)-f(1);
Fmx = ( f(end)-f(1) +df); dt = 1/Fmx; N = length(sf); T = dt*N;
%t=-T/2:dt:T/2-dt; t = 0:dt:T-dt;
sff = fftshift(sf); st = Fmx*ifft(sff);
function [f,sf]= T2F(t,st)
%This is a function using the FFT function to calculate a signal's Fourier %Translation
%Input is the time and the signal vectors,the length of time must greater %than 2
%Output is the frequency and the signal spectrum dt = t(2)-t(1); T=t(end); df = 1/T; N = length(st);
f=-N/2*df:df:N/2*df-df; sf = fft(st);
sf = T/N*fftshift(sf);
function [ t,st] = lpf( f,sf,B) df=f(2)-f(1); T=1/df;
hf=zeros(1,length(f));
bf=[-floor(B/df):floor(B/df)]+floor(length(f)/2); hf(bf)=1; yf=hf.*sf; [t,st]=F2T(f,yf); st=real(st); end
运行>> am_xianggan()
相关推荐: