freq_offset.m
来自「一个教你如何用matlab写mimo系统的程序」· M 代码 · 共 48 行
M
48 行
function [freq_diff, delta_theta, alpha]=freq_offset(inphase, quad, fs, fc)% [freq_diff, delta_theta, alpha]=freq_offset(inphase, quad, fs, fc)%% Output:% freq_diff - The resulting difference in carrier-frequency between transmitter and receiver.% delta_theta - Returns the phase-shift per sample.% alpha - Is the factor, where alpha fs2 = alpha * fs1%% inphase - Inphase part after downconversion and LP-filtering% quad - Quad part after downconversion and LP-filtering% fs - Used sampling frequency% fc - Carrier frequency used in transmitter%% Short Theoretical Background for the Function:% % Compensating for rotation on sinus-signal.% Assuming rotation is less than one halfcircle!!!!!!% This function needs the sinussignal to be present from% first sampel to the last. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Function part of simulation for Space-Time%%% coding project, group Grey-2001.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Author: Stefan Uppg錼d% Date: 29-03-2001% Version: 1.0% Revision (Name & Date & Comment):%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%complex_signal_in = complex(inphase, quad);fi = angle(complex_signal_in); % Phase for downconverted signalA = [[1:length(fi)]' ones(length(fi),1)]; % Solving least-square for straight-line equationy = fi';x = A\y; % x = A\y, d鋜 x = [k m]'first_angle = x(2);end_angle = x(1)*length(fi)+x(2);freq_diff = (fs/(2*pi)) * (end_angle - first_angle) * (1/length(fi));figure(9), plot(fi), hold on, plot([1 length(fi)], [x(2) x(2)+x(1)*length(fi)], 'red'), hold off;delta_theta = (end_angle - first_angle) / length(fi);alpha = 1/(1-(freq_diff/fc));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?