使用蒙特卡罗方法来生成水下可见光通信海水信道的matlab代码,信道长度1米,并使用这段代码来生成基于LMS均衡技术的水下光通信matlab仿真代码,结果用均衡后的和无均衡的在同一张图里做对比,要明显的突出均衡后的误码率要低于无均衡的,均衡后的3dB带宽要高于无均衡的
时间: 2024-05-01 07:20:53 浏览: 53
水下可见光通信信道的matlab代码:
```matlab
clear all;
close all;
clc;
n = 10000; % 信道长度
L = 1; % 信道长度为1米
h = 0.01; % 每个间隔0.01米
% 海水光学参数
c = 3e8; % 光速
v = 1.33e-3; % 海水折射率
lamda = 400e-9; % 光波长
B = c/(2*L)*sqrt(1-v^2)*lamda; % 信道带宽
% 生成水下可见光信道
for i=1:n
d(i) = (i-1)*h;
r(i) = 0.5 + 0.5*cos(2*pi*d(i)/L);
alpha(i) = exp(-(d(i)^2)/(2*(0.1)^2)); % 表示海水的吸收率
beta(i) = exp(-(d(i)^2)/(2*(0.1)^2)); % 表示海水的散射率
g(i) = r(i)^2*alpha(i)*beta(i);
end
% 画出信道响应曲线
figure(1);
plot(d,g);
xlabel('信道距离(m)');
ylabel('信道增益(dB)');
title('水下可见光通信信道');
```
基于LMS均衡技术的水下光通信matlab仿真代码:
```matlab
clear all;
close all;
clc;
n = 10000; % 信道长度
L = 1; % 信道长度为1米
h = 0.01; % 每个间隔0.01米
% 海水光学参数
c = 3e8; % 光速
v = 1.33e-3; % 海水折射率
lamda = 400e-9; % 光波长
B = c/(2*L)*sqrt(1-v^2)*lamda; % 信道带宽
% 生成水下可见光信道
for i=1:n
d(i) = (i-1)*h;
r(i) = 0.5 + 0.5*cos(2*pi*d(i)/L);
alpha(i) = exp(-(d(i)^2)/(2*(0.1)^2)); % 表示海水的吸收率
beta(i) = exp(-(d(i)^2)/(2*(0.1)^2)); % 表示海水的散射率
g(i) = r(i)^2*alpha(i)*beta(i);
end
% 发送端发送的数据
data = randi([0 1],1,10000);
Tx = 2*data-1;
% 发送数据经过信道后接收端接收到的信号
Rx = zeros(1,n);
for i=1:n
Rx(i) = Tx(i)*sqrt(g(i));
end
% 加入高斯白噪声
snr = 10; % 信噪比
sigma = sqrt(1/(2*B*10^(snr/10))); % 噪声标准差
noise = sigma*randn(1,n);
Rx = Rx + noise;
% LMS均衡器
mu = 0.01; % 步长
N = 10; % 窗口长度
w = zeros(1,N); % 初始权值
error = zeros(1,n); % 记录均衡器的误差
for i=N+1:n
x = Rx(i:-1:i-N+1); % 窗口信号
y = w*x.'; % 均衡器的输出
error(i) = Tx(i) - y; % 均衡器的误差
w = w + mu*error(i)*x; % 更新权值
end
% 画出均衡器的误差曲线
figure(2);
plot(error.^2);
xlabel('采样点');
ylabel('误差平方');
title('LMS均衡器的误差');
% 误码率和3dB带宽的计算
BER_eq = zeros(1,30);
BER_no_eq = zeros(1,30);
BW_eq = zeros(1,30);
BW_no_eq = zeros(1,30);
for k=1:30
snr = k-1;
sigma = sqrt(1/(2*B*10^(snr/10))); % 噪声标准差
noise = sigma*randn(1,n);
Rx = Rx + noise;
% 均衡后的误码率和3dB带宽
data_hat_eq = zeros(1,10000);
for i=N+1:n
x = Rx(i:-1:i-N+1);
y = w*x.';
data_hat_eq(i-N) = y>0;
end
BER_eq(k) = sum(abs(data - data_hat_eq))/n;
BW_eq(k) = B*sum(abs(fftshift(fft(w,1024))).^2)/max(abs(fftshift(fft(w,1024))).^2);
% 无均衡的误码率和3dB带宽
data_hat_no_eq = zeros(1,10000);
for i=1:n
data_hat_no_eq(i) = Rx(i)>0;
end
BER_no_eq(k) = sum(abs(data - data_hat_no_eq))/n;
BW_no_eq(k) = B*sum(abs(fftshift(fft(Rx,1024))).^2)/max(abs(fftshift(fft(Rx,1024))).^2);
end
% 画出误码率和3dB带宽的对比图
figure(3);
semilogy(0:29,BER_no_eq,'b-o');hold on;
semilogy(0:29,BER_eq,'r-^');
xlabel('信噪比(dB)');
ylabel('误码率');
title('无均衡和均衡后的误码率比较');
legend('无均衡','均衡');
grid on;
figure(4);
plot(0:29,BW_no_eq,'b-o');hold on;
plot(0:29,BW_eq,'r-^');
xlabel('信噪比(dB)');
ylabel('3dB带宽(Hz)');
title('无均衡和均衡后的3dB带宽比较');
legend('无均衡','均衡');
grid on;
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)