-
通信系统模型
Information
source
And input transducer
Source
Coding
Channel
Encoding
Digital
Modulation
Channel
Output
transducer
Source
decoding
Channel
Decoding
Digital
Demodulation
信源
信号源函数
Signal Sources
randerr
-
Generate bit error patterns.
randint
-
Generate matrix of uniformly distributed random
integers.
randsrc
- Generate random matrix using
prescribed alphabet.
- Generate
pseudorandom noise sequences (See also: SEQGEN
objects).
wgn
-
Generate white Gaussian noise.
以
randsrc (1,10,[0 1;0.5
0.5])
为例
产生
1*10
的
0
、
1
矩阵,
0
、
1
出现的概率均为
0.5
;
此外<
/p>
Matlab
产生随机数:
rand
rand(n)
:生成
p>
0
到
1
之间的
p>
n
阶随机数方阵
rand(m,n)
:生成
0
到
1
之间的
m×
n
p>
的随机数矩阵
randn
randn
()命令是产生白噪声的,白噪声应该是
0
均值,方差为
1
的一组数;
同
rand
有
randn(n)
,
randn(m,n)
rand
是
0-1
的均匀分布,
randn
是均值为
0
方差为
1
的正态分布
randint
randint(m,n,[1
N])
:生成
m×
n
的在
1
到
N
之间的随机整数矩阵,其效果与
randint(m,n,
N+1)
相同。
Matlab
随机数生成函数:
betarnd
贝塔分布的随机数生成器
binornd
二项分布的随机数生成器
chi2rnd
卡方分布的随机数生成器
exprnd
指数分布的随机数生成器
frnd f
分布的随机数生成器
gamrnd
伽玛分布的随机数生成器
geornd
几何分布的随机数生成器
hygernd
超几何分布的随机数生成器
lognrnd
对数正态分布的随机数生成器
nbinrnd
负二项分布的随机数生成器
ncfrnd
非中心
f
分布的随机数生成器
nctrnd
非中心
t
分布的随机数生成器
ncx2rnd
非中心卡方分布的随机数生成器
normrnd
正态(高斯)分布的随机数生成器
poissrnd
泊松分布的随机数生成器
raylrnd
瑞利分布的随机数生成器
trnd
学生氏
t
< br>分布的随机数生成器
unidrnd
离散均匀分布的随机数生成器
unifrnd
连续均匀分布的随机数生成器
weibrnd
威布尔分布的随机数生成器
Matlab
取整:
(1)fix(x) :
截尾取整
.
>> fix( [3.12 -3.12])
ans =
3
-3
(2)floor(x):
不超过
x
的最大整数
.(
高斯取整
)
>> floor( [3.12 -3.12])
ans =
3
-4
(3)ceil(x) :
大于
x
的最小整数
>> ceil(
[3.12 -3.12])
ans =
4
-3
(4) round
(x) :
四舍五入取整
>>
round(3.12 -3.12)
ans =
0
>> round([3.12 -3.12])
ans =
3
-3
信源编译码
信源编码函数(效果:提
高有效性、降低可靠性,信道编码相反)
Source
Coding
arithdeco
- Decode binary code using
arithmetic decoding.
arithenco
- Encode a
sequence of symbols using arithmetic coding.
compand
- Source code
mu-law or A-law compressor or expander.
dpcmdeco
- Decode using differential
pulse code modulation.
dpcmenco
-
Encode using differential pulse code modulation.
dpcmopt
- Optimize
differential pulse code modulation parameters.
Huffmandeco
-
Huffman decoder.
huffmandict
-
Generate
Huffman
code
dictionary
for
a
source
with
known
probability
model.
huffmanenco - Huffman
encoder.
lloyds
- Optimize quantization
parameters using the Lloyd algorithm.
quantiz
- Produce a
quantization index and a quantized output value.
以霍夫曼编码为例:
letters
= [1:6]; % Distinct symbols the data source can
produce
p = [.5 .125 .125 .125 .0625
.0625]; % Probability distribution
[dict,avglen] = huffmandict(letters,p);
% Get Huffman code.
sig
= randsrc(1,20,[letters; p]) % Create
data using p.
comp =
huffmanenco(sig,dict)
%
Encode the data.
deco =
huffmandeco(comp,dict) % Decode the encoded
signal.
equal = isequal(sig,deco) %
Check whether the decoding is correct.
调制解调
Digital Modu
lation/Demodulation
(数字调制
/
解调函数)
dpskmod -
Differential phase shift keying modulation.
dpskdemod - Differential phase shift
keying demodulation.
fskmod - Frequency
shift keying modulation.
fskdemod -
Frequency shift keying demodulation.
genqammod - General quadrature
amplitude modulation.
genqamdemod -
General quadrature amplitude demodulation.
modnorm - Scaling factor for
normalizing modulation output.
mskmod -
Minimum shift keying modulation.
mskdemod - Minimum shift keying
demodulation.
oqpskmod - Offset
quadrature phase shift keying modulation.
oqpskdemod - Offset quadrature phase
shift keying demodulation
pammod -
Pulse amplitude modulation.
pamdemod -
Pulse amplitude demodulation.
pskmod -
Phase shift keying modulation.
pskdemod - Phase shift keying
demodulation.
qammod -
Quadrature amplitude modulation.
qamdemod - Quadrature amplitude
demodulation.
以
B
PSK
为例:
x=[0 1 0 1
1 0 1 1];
scatterplot(pskmod(x,2,0));
p>
%Bpsk
调制并画星座图,初始相位为
0
pskdemod(pskmod(x,2,0),2);<
/p>
%
解调
s=(
x*2-1);
%BPSK
调制
c=(s>0);
%BPSK
解调
以
< br>QPSK
为例:
function
ModulateSignal=QPSKModulate(SignalData)
data=SignalData;
for
jdata=1:size(data,1)
m=1;
for
idata=1:size(data,2)/2
%QPSK modulation
packet(1:2)=[data(jdata,2*idata-1),data(jdata,2*id
ata)];
if
packet==[0,0]
symbol(jdata,m)=i;
elseif
packet==[0,1]
symbol(jdata,m)=1;
elseif
packet==[1,0]
symbol(jdata,m)=-1;
elseif
packet==[1,1]
symbol(jdata,m)=-i;
end
m=m+1;
end
;
end
ModulateSignal=symbol;
信道编译码
卷积码及维特比译码
(
2,1,3
)卷积码
function
[Convolu
tionalCode,Trellis]=ConvolutionalEncoding(SourceCo
de)
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%
%%%%
该函数实现
(2,1,3)
卷积编码
%%%%
其中
SourceCode<
/p>
为要编码的原始序列
%%%%Conv
olutionalCode
为编好的码字
%%%%Trellis
为网格表示
% zjm
%
Version 1.00
%
2010-11-25
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%%%
%
第一个参数为约束长度。第二个参数为输入说出关系
Trellis=poly2trellis(3,[7
5]
);
%(2,1,3)
卷积码的网格表示
,g1=[1
1
1];g2=[1
0
1];
ConvolutionalCode=convenc(S
ourceCode,Trellis);
%
卷积编码
function
DecodedCode=Convolu
tionalDecoding(EncodedCode)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%
p>
%%%%
该函数实现
(2,1,3)
卷积译码
%%%%
其中
EncodedCode
为要译码的序列
< br>
%%%%DecodedCode
为译好的码字
% zjm
% Version 1.00
% 2010-11-25
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%%%%%
Trellis=poly2trellis(3,[7 5]);
%(2,1,3)
卷积码网格表示
DecodedCode=vit
dec(EncodedCode,Trellis,3,
'trunc'
,
'hard'
);
%
p>
维特比译码,
硬
判决
分组码:
>> x=encode([1 0 1 1],7,4,'hamming');
>> y=decode(x,7,4,'hamming');
信道
瑞利(莱斯)衰落信道
复数信号:
瑞利衰落信道(
Rayleigh fading chann
el
)是一种无线电信号传播环境的统计模型。这种模型
假设信
号通过无线信道之后,其信号幅度是随机的,即
“
衰落
”
,并且其包络服从瑞利分布。
在无线通信信道环境中,电磁波经过反射折射散射等多条路径传播到达接收机后,
总信号
的强度服从瑞利分布。
同时由于接收机的移动及其他原因,
信号强度和相位等特性又在起
伏变化,
故称为瑞利衰落。
两个正交高斯噪声信号之和的包络服从瑞利分布。
单输入单输出系统
Rayleigh
衰落信道可以
建模为:
y=hx+n;
其中
h=(r
andn+jrandn)/sqrt(2);
h=(randn(1,10)+i*
randn(1,10))/sqrt(2);
产生幅值均值
为
1,
服从瑞利分布
1*10
的矩阵。
实数信号:
在
matlab
中
rayleigh
信道的随机数可以由
random
函数
或者
raylrnd
产生,归一化之后为
h=raylrnd(1,1,10) /sqrt(pi/2);