文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
基于MATLAB的VSB程序及其波形图 一. 运行程序(注意这5个程序要分开写成5份)
% ---------------------------------------
% 显示模拟调制的波形及其解调方法VSB,文件名:VSB.m % Signal dt=0.001; fmax=6; fc=45; T=5; N=T/dt;
t=[0:N-1]*dt;
mt=sqrt(2)*(cos(2*pi*fmax*t)+sin(2*pi*0.5*fmax*t)); % VSB modulation
s_vsb=mt.*cos(2*pi*fc*t); B1=0.2*fmax; B2=1.2*fmax;
[f,sf]=FFT_SHIFT(t,s_vsb); [t,s_vsb]=vsbmd(f,sf,B1,B2,fc); % Power Spectrum Density [f,sf]=FFT_SHIFT(t,s_vsb); PSD=(abs(sf).^2)/T; % Plot VSB and PSD figure(1) subplot(211)
plot(t,s_vsb);hold on; plot(t,mt,'r--');
title('VSB调制信号'); xlabel('t'); subplot(212) plot(f,PSD);
axis([-2*fc 2*fc 0 max(PSD)]); title('VSB信号功率谱'); xlabel('f');
二. 调用程序1
% 调用函数
function [f, sf]=FFT_SHIFT(t, st)
%This function is FFT to calculate a signal’s Fourier transform
%Input: t: sampling time , st : signal data. Time length mustgreater thean 2 %output: f : sampling frequency , sf: frequen %output is the frequency and the signal spectrum
1
文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
dt=t(2)-t(1); T=t(end); df=1/T;
N=length(t); f=[-N/2:N/2-1]*df; sf=fft(st);
sf=T/N*fftshift(sf);
三. 调用程序2 function [t,st]=IFFT_SHIFT(f,Sf)
df=f(2)-f(1);
fmax=(f(end)-f(1)+df); dt=1/fmax; N=length(f); t=[0:N-1]*dt; Sf=fftshift(Sf); st=fmax*ifft(Sf); st=real(st)
四. 调用程序3
function [t,st]=vsbmd(f,sf,B1,B2,fc)
% This function is a residual bandpass filter
% Inputs f: sample frequency, sf: frequency spectrum data
% B1: residual bandwidth, B2: highest freq of the baseband signal % Outputs t:sample time, st: signal data df=f(2)-f(1); T=1/df;
hf=zeros(1,length(f));
bf1=[floor((fc-B1)/df):floor((fc+B1)/df)]; bf2=[floor((fc-B1)/df)+1:floor((fc+B2)/df)]; f1=bf1+floor(length(f)/2); f2=bf2+floor(length(f)/2); stepf=1/length(f1); hf(f1)=0:stepf:1-stepf; hf(f2)=1;
f3=-bf1+floor(length(f)/2); f4=-bf2+floor(length(f)/2); hf(f3)=0:stepf:(1-stepf); hf(f4)=1; yf=hf.*sf;
[t,st]=IFFT_SHIFT(f,yf); st=real(st);
2
文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
五. 波形图
3