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

📄 cpfskdemod_new.m

📁 一个仿真测试4FSK信号的matlab环境GUI程序。可以查看基带IQ波形、眼图、星座图。并可以仿真高斯白噪声、瑞利衰减对信号的影响。
💻 M
字号:
function z = cpfskdemod_new(y,M,h,nSamp,Fd)
% Continous phase FSK demodulation program.
%       y : the the modulation baseband complex signal
%       M : M-array;
%       h : modulation index;
%   nSamp : samples per symbol;
%      Fd : symbol rate

%   written by zhengliangde, hyt CO.,LTD.
%   contact me : harlemon@126.com
%   date: 2006.3.20

% -------------------------
%y = evalin('base','y');
%M = 4;
%h = 0.27;
%nSamp = 8;
%Fd = 4800;
% -------------------------
Fs = nSamp*Fd;
[nRow,nChan] = size(y);
if nChan~=1
    error('This program could not process multiple channel signal.');
    return
end

samptime = 1/Fs;

z = zeros(nRow/nSamp,1);

% time vector for one symbol
t = [0:1/Fs:(nSamp-1)/Fs]';
phase = t*([-(M-1):2:(M-1)]*pi*h*Fd);
tones = exp(-j*phase);

for i = 1:nRow/nSamp
    yTemp = y((i-1)*nSamp+1 : i*nSamp);
    % Replicate the received FSK signal to multiply with the M tones
    yTemp = yTemp(:, ones(M,1));
    % Multiply against the M tones
    yTemp = yTemp .* tones;
    % Perform the integrate and dump, then get the magnitude.  Use a
    % subfunction for the integrate and dump, to omit the error checking.
    yMag = abs(intanddump(yTemp, nSamp));
    % Choose the maximum and assign an integer value to it.  Subtract 1 from the
    % output of MAX because the integer outputs are zero-based, not one-based.
    [maxVal maxIdx] = max(yMag, [], 2);
    z(i) = maxIdx - 1;
end
%assignin('base','z',z);

% ------------------------------------------------------------------------------
function y = intanddump(x, Nsamp)
%INTANDDUMP Integrate and dump.
%   Y = INTANDDUMP(X, NSAMP) integrates the signal X for 1 symbol period, then
%   outputs one value into Y. NSAMP is the number of samples per symbol.
%   For two-dimensional signals, the function treats each column as 1
%   channel.
%

% --- Assure that X, if one dimensional, has the correct orientation --- %
wid = size(x,1);
if(wid ==1)
    x = x(:);
end

[xRow, xCol] = size(x);
x = mean(reshape(x, Nsamp, xRow*xCol/Nsamp), 1);
y = reshape(x, xRow/Nsamp, xCol);      

% --- restore the output signal to the original orientation --- %
if(wid == 1)
    y = y.';
end

% EOF --- intanddump.m

⌨️ 快捷键说明

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