git-svn-id: http://moon:8086/svn/matlab/trunk@40 801c6759-fa7c-4059-a304-17956f83a07c
59 lines
1.4 KiB
Matlab
59 lines
1.4 KiB
Matlab
function wiener_eval(N, SNR, sigm)
|
|
|
|
close all;
|
|
|
|
USE_TD = 0;
|
|
|
|
s = exp(j*4*pi.*(0:N-1)'/N);
|
|
h = -exp(j*4*pi.*(0:N-1)'/N) .* (1+(0.5 - 0.5*cos(2*pi.*(0:N-1)'/N)));
|
|
r = awgn(h.*s, SNR);
|
|
|
|
hr = r./s;
|
|
|
|
if USE_TD
|
|
[ss, gs, rxy, ryy] = wiener_td(s, r, sigm);
|
|
ss = ss./abs(ss);
|
|
|
|
[hs, gh, rxyh, ryyh] = wiener_td(h, hr, sigm);
|
|
|
|
figure
|
|
plot(rxy); grid; legend('rxy');
|
|
figure
|
|
plot(ryy); grid; legend('ryy');
|
|
|
|
else
|
|
[ss, gs] = wiener_fd(s, r, sigm);
|
|
ss = ss./abs(ss);
|
|
|
|
[hs, gh] = wiener_fd(h, hr, sigm);
|
|
end
|
|
|
|
figure;
|
|
subplot(2, 1, 1)
|
|
plot(0:N-1, abs(h), 'b-', 0:N-1, abs(hr), 'g-', 0:N-1, abs(hs), 'r-'); grid; legend('|h|', '|h_{r}|', '|h_{s}|');
|
|
subplot(2, 1, 2)
|
|
plot(0:N-1, angle(h), 'b-', 0:N-1, angle(hr), 'g-', 0:N-1, angle(hs), 'r-'); grid; legend('phi(h)', 'phi(h_{r})', 'phi(h_{s})');
|
|
|
|
figure;
|
|
plot(real(s), imag(s), 'bO', real(r), imag(r), 'rx', real(ss), imag(ss), 'm+'); grid; legend('s', 'r', 'W*r');
|
|
|
|
figure;
|
|
plot(real(gs), imag(gs), 'b+'); grid; legend('gh');
|
|
|
|
figure;
|
|
plot(abs(gh)); grid; legend('|gs|');
|
|
|
|
function h = channel(N, L, phi_max, omega_d_max, delay_max)
|
|
k = 1; % time
|
|
for l=1:L % frequency
|
|
hsum = 0;
|
|
for n=1:N
|
|
delay_n = delay_max*(1+fix(rand));
|
|
omega_n = omega_d_max*(1 - 2*rand());
|
|
phi_n = phi_max*pi*(1 - 2*rand());
|
|
hsum = hsum + exp(j*0*(phi_n+2*pi*omega_n*k + 2*pi*delay_n/L*l))
|
|
end
|
|
h(l,:) = 1/sqrt(N) * hsum;
|
|
end
|
|
|