📄 freq_offset.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -