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

📄 geterror.m

📁 matlab实现汉明码 matlab实现汉明码
💻 M
字号:
function out=geterror(PB)
%out=geterror(PB)
%This function takes in the channel bit error probability and returns the
%corresponding error bit probablity in the decoded signal.
G=[[0,1,1;1,0,1;1,1,0;1,1,1],eye(4)];
sig=uint8(wavread('VoiceIn.wav')*255);
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);

%Calculating the Syndrome ...
Syndromes=Mod2MatMul(CorruptedSig7bits,transpose(H));
%Error Correction ...
Recovered7bit=xor(errorpattern(Syndromes),CorruptedSig7bits);
%Dropping the parity bits ... 
Recovered7bit(:,[4,5,6,7]);
%Converting to integers ...
Recovered=FourBitToInt(Recovered7bit(:,[4,5,6,7]));
channellerror=sum(sum(xor(CorruptedSig7bits,encoded)));
if channellerror==0
    out=0;
else
    out=sum(sum(xor(Recovered7bit,encoded)))/channellerror*PB;
end
end

⌨️ 快捷键说明

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