pcm_decode.m
来自「Matlab 模拟 CDMA 直接扩频。m序列生成矩阵为p(x) = 1 + x」· M 代码 · 共 34 行
M
34 行
function [ output ] = pcm_decode( bitsIn )%UNTITLED1 Summary of this function goes here% Detailed explanation goes hereSLENGTH = length(bitsIn)/8;bytesIn = zeros(3,SLENGTH);for i = 1:SLENGTH, bytesIn(1,i) = bitsIn(8*(i-1)+1); for j = 2:4, bytesIn(2,i) = bytesIn(2,i) + bitsIn(8*(i-1)+j)*2^(4-j); end for j = 5:8 bytesIn(3,i) = bytesIn(3,i) + bitsIn(8*(i-1)+j)*2^(8-j); endend%==>== DECODE ====%output = zeros(1,SLENGTH);for i = 1:SLENGTH % in case! if bytesIn(2,i) == 0, preByte = (1/2)^7; preByte1 = 0; else preByte = (1/2)^(8-bytesIn(2,i)); preByte1 = preByte; end output(i) = (-1)^(bytesIn(1,i))*... (preByte1+... preByte*(bytesIn(3,i))/16);endclear preByte;clear preByte;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?