- improved
git-svn-id: http://moon:8086/svn/matlab/trunk@132 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
+9
-8
@@ -46,25 +46,26 @@ N = Nc*Nspc*slave_oversample;
|
|||||||
assert (N == length(x));
|
assert (N == length(x));
|
||||||
|
|
||||||
# Create slave
|
# Create slave
|
||||||
pc = 0.5 + perr;
|
phase_lo = 0.0 + perr;
|
||||||
dfreq = freq/slave_oversample;
|
dfreq = freq/slave_oversample;
|
||||||
dpc = 0;
|
omega = 0;
|
||||||
|
|
||||||
sample_count = slave_oversample;
|
sample_count = slave_oversample;
|
||||||
for n=1:N,
|
for n=1:N,
|
||||||
perr = phase_det(pc, x(n));
|
phase = mod(phase_lo - 0.5, 1);
|
||||||
|
perr = phase_det(phase, x(n));
|
||||||
sample_count = sample_count - 1;
|
sample_count = sample_count - 1;
|
||||||
if sample_count == 0,
|
if sample_count == 0,
|
||||||
sample_count = slave_oversample;
|
sample_count = slave_oversample;
|
||||||
else
|
else
|
||||||
perr = 0;
|
perr = 0;
|
||||||
end
|
end
|
||||||
_lo(n) = mod(pc - 0.5, 1);
|
_lo(n) = phase_lo;
|
||||||
dpc = dfreq - (klag*lag + klead*perr);
|
omega = dfreq - (klag*lag + klead*perr);
|
||||||
pc = mod(pc + dpc, 1);
|
phase_lo = mod(phase_lo + omega, 1);
|
||||||
lag = lag + perr;
|
lag = lag + perr;
|
||||||
_perr(n) = perr;
|
_perr(n) = perr;
|
||||||
_dpc(n) = dpc;
|
_omega(n) = omega;
|
||||||
end
|
end
|
||||||
|
|
||||||
function perr = phase_det(lo, x)
|
function perr = phase_det(lo, x)
|
||||||
@@ -76,7 +77,7 @@ subplot(3, 1, 1)
|
|||||||
plot(1:N, _lo, 1:N, x); legend('Lo', 'x'); grid
|
plot(1:N, _lo, 1:N, x); legend('Lo', 'x'); grid
|
||||||
|
|
||||||
subplot(3, 1, 2)
|
subplot(3, 1, 2)
|
||||||
plot(1:N, _dpc); legend('f'); grid
|
plot(1:N, _omega); legend('f'); grid
|
||||||
|
|
||||||
subplot(3, 1, 3)
|
subplot(3, 1, 3)
|
||||||
plot(1:N, _perr); legend('p'); grid
|
plot(1:N, _perr); legend('p'); grid
|
||||||
|
|||||||
Reference in New Issue
Block a user