⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.m

📁 在matlab下模擬hamming codeing的編解碼過程,碼率為7/11,提供初學者學習
💻 M
字号:
tic
% A main script to test the functions..


G=[[0,1,1;1,0,1;1,1,0;1,1,1],eye(4)];
sig=uint8(wavread('elen849_1.wav')*255);
%Play the original speech
wavplay(sig,8000);
%Plot the original speech
subplot(2,2,1),plot(sig);
title('Orginal Speech');

encoded=linearencode(sig,G);
%Bit error probablity
PB=0.01;
H=[eye(3),transpose([0,1,1;1,0,1;1,1,0;1,1,1])];
ChannelError=rand(size(encoded))<=PB;
CorruptedSig7bits=xor(ChannelError,encoded);
%Plot the Corrupted signal without encoding
%encoded(:,[5,6,7,8])-

Corrupted4bit=CorruptedSig7bits(:,[4,5,6,7]);
%sum(encoded(:,[5,6,7,8])-Corrupted4bit)
Corrupted=FourBitToInt(Corrupted4bit);
%Plot the corrupted speech
subplot(2,2,2),plot(Corrupted);
title('Corrupted Speech - by just ignoring the parity bits');
%play the corrupted signal - without encoding/decoding
wavplay(uint8(Corrupted),8000);

%Calculating the Syndrome ...
Syndromes=Mod2MatMul(CorruptedSig7bits,transpose(H));
%Error Correction ...
Recovered7bit=xor(errorpattern(Syndromes),CorruptedSig7bits);
%Dropping the parity bits ... 
Recovered4bit=Recovered7bit(:,[4,5,6,7]);
%Converting to integers ...
Recovered=FourBitToInt(Recovered4bit);

%Plot the recovered speech
subplot(2,2,3),plot(Recovered);
title('Recovered speech - after linear block encoding and decoding');
%play the corrupted signal - without encoding/decoding
wavplay(uint8(Recovered),8000);
toc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -