资源简介
应用Matlab产生各种数字调制信号以及在AWGN下的传输结果。包括AM,QPSK,BPSK等,应该对初学者有一定帮助
代码片段和文件信息
function [smod]=generate_mod_signal(typetotal_timefcfssymbol_rate)
% total_time : length of signal in seconds
% fc : carrier frequency
% fs : samplling frequency
% symbol_rate : symbol rate
% type : modulation type
if fs < 2*fc
disp(‘error‘);
end
alpha=0.5;
ts=1/fs;
T=1/symbol_rate;
t=ts:ts:total_time;
N=floor(total_time*fs);
a=0.85; % modulation factor
d=randn(1N);
[numden]=butter(50.01);
bs=filter(numdend);
bs=bs/max(abs(bs));
t=ts:ts:total_time;
te=-T+2*ts:2*ts:T;
g_t=sinc(te/T).*cos(pi*alpha*te/T)./(1-(4*alpha*te/(2*T)).^2+eps);
switch type
case 1 % AM
s=(1+a*bs).*cos(2*pi*fc*t);
mod=1;
case 2 % AM-DSB
s=bs.*cos(2*pi*fc*t);
mod=2;
case 3 % AM-LSB
s=bs.*cos(2*pi*fc*t)+imag(hilbert(bs)).*sin(2*pi*fc*t);
mod=3;
case 4 % AM-USB
s=bs.*cos(2*pi*fc*t)-imag(hilbert(bs)).*sin(2*pi*fc*t);
mod=4;
case 5 % FM
k=0.2*fc;
int_bs(1)=0;
for i=1:length(t)-1;
int_bs(i+1)=int_bs(i)+bs(i)*ts;
end
s=cos(2*pi*fc*t+2*pi*k*int_bs);
mod=5;
case 6 % AM-FM-combined
% k=0.02*fc;
% int_bs(1)=0;
% for i=1:length(t)-1;
% int_bs(i+1)=int_bs(i)+bs(i)*ts;
% end
temps=amod(bsfcfs‘fm‘0.2*fc);
ms=hilbert(temps).*bs;
s=real(ms);
mod=6;
case 7 % 2-ASK
d=randint(1floor(total_time*symbol_rate)2);
dmap=modmap(dsymbol_ratefs‘ask‘);
g_tr=repmat(g_t1length(d));
s=dmap.*g_tr.*cos(2*pi*fc*t);
mod=7;
case 8 % 4-ASK
d=randint(1floor(total_time*symbol_rate)4);
dmap=modmap(dsymbol_ratefs‘ask‘);
g_tr=repmat(g_t1length(d));
s=dmap.*g_tr.*cos(2*pi*fc*t);
mod=8;
case 9 % 16-QAM
d=randint(1floor(total_time*symbol_rate)16);
s_r=dmod(dfcsymbol_ratefs‘qask‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=9;
case 10 % 2-PSK
d=randint(1floor(total_time*symbol_rate)2);
s_r=dmod(dfcsymbol_ratefs‘psk‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=10;
case 11% 4-PSK
d=randint(1floor(total_time*symbol_rate)4);
s_r=dmod(dfcsymbol_ratefs‘psk‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=11;
case 12 % 8-PSK
d=randint(1floor(total_time*symbol_rate)8);
s_r=dmod(dfcsymbol_ratefs‘psk‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=12;
case 13 % 2-FSK
d=randint(1floor(total_time*symbol_rate)2);
s_r=dmod(dfcsymbol_ratefs‘fsk‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=13;
case 14 % 4-FSK
d=randint(1floor(total_time*symbol_rate)4);
s_r=dmod(dfcsymbol_ratefs‘fsk‘);
g_tr=repmat(g_t1length(d));
s=g_tr.*s_r;
mod=14;
case 15 % MFSK
d=randint(1floor(total_time*symbol_rate)2);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3116 2006-05-09 09:37 generate_mod_signal.m
----------- --------- ---------- ----- ----
3334 2
- 上一篇:随机集目标跟踪开发包
- 下一篇:s变换的matlab程序
评论
共有 条评论