I tried implementing a matched filter to improve sensing SNR using the code below, but I did not get good results. If anyone knows a better way, please help.

s_t = (EdeltaS*(lamda^2)/(64*(pi^3)*(r_max^2)))...
*(HBR'*(wc*wc'+ws*ws')*(a_RIS_tem*a_RIS_tem')*diag(ome)*diag(ome')*HBR*HBR'*(a_RIS_tem*a_RIS_tem')*diag(ome)*diag(ome')*HBR*(wrx_in*wrx_in')*sin(theta_tem));
s_t_vec = s_t(:); % reshape s_t into a coloumn vector
% Add AWGN to the transmitted signal
r_target = awgn(s_t_vec, 10^(-9));
% Apply the matched filter
template = conj(s_t_vec(end:-1:1));
filtered_signal = conv(r_target, template, 'same');
% Compute SNR of the filitered signal
SNR = abs(filtered_signal).^2 ./ (var(r_target) + var(filtered_signal));

 Accepted Answer

There's no need of a completely new approach according to me, you can just make some improvements in your code for better functionality.
1) Change the SNR value used in the awgn function. A value of 10^(-9) may result in an extremely high SNR, leading to unrealistic noise levels. Adjust the SNR value based on your signal characteristics and desired noise level.
2) Instead of converting the s_t matrix into a column vector and then applying the matched filter using conv, you can directly perform matrix multiplication to improve memory efficiency. Refer to the following code.
template = conj(flipud(s_t));
filtered_signal = filter2(template, r_target, 'same');
3) Directly use the power expressions in the calculation of the SNR, instead of squared magnitudes expressions. Refer to the following code.
SNR = abs(filtered_signal).^2 / var(filtered_signal);
Hope this helps.

4 Comments

Can you explain why the denominator is var(filtered_signal) and not var(r_target)? because SNR = signal power/ noise power
I apologize for the confusion caused by the previous response. You are correct in stating that the SNR is calculated as the ratio of signal power to noise power.
In the context of a matched filter, the filtered signal is expected to contain the desired signal component while minimizing the effects of noise. Therefore, it is more appropriate to consider the noise power as the variance of the difference between the received signal (r_target) and the filtered signal. The difference represents the residual noise after applying the matched filter.
Therefore, the correct calculation for SNR in your case should be:
noise_power = var(r_target - filtered_signal);
SNR = abs(filtered_signal).^2 ./ noise_power;
Here, noise_power represents the estimated power of the residual noise after applying the matched filter.
Thank you for clarification, one more question, my maximum transmit power is 30 dB , how to plot the SNR for each transmit power level?
To plot the SNR for each transmit power level, you can modify the code to loop over a range of transmit power levels, apply the matched filter for each power level, and plot the resulting SNR values. Refer to the following code for the same.
% Generate a longer training sequence
train_seq = repmat(s_t_vec, 10, 1);
% Define the range of transmit power levels
p_range = 0:2:30;
% Initialize the SNR vector
SNR = zeros(size(p_range));
% Loop over the transmit power levels
for i = 1:length(p_range)
% Set the transmit power level
p = 10^(0.1*p_range(i));
% Generate the transmitted signal
s_t = ... % code to generate the transmitted signal
% Add noise to the transmitted signal with a higher SNR threshold
r_target = awgn(s_t, 20);
% Apply the matched filter
template = conj(s_t(end:-1:1));
filtered_signal = conv(r_target, template, 'same');
% Compute the SNR of the filtered signal
SNR(i) = abs(filtered_signal).^2 ./ (var(r_target) + var(filtered_signal));
end
% Plot the SNR vs. transmit power
plot(p_range, SNR);
xlabel('Transmit Power (dB)');
ylabel('SNR');
title('SNR vs. Transmit Power');
Please keep in mind to change each parameter value to a value relevant to your model.

Sign in to comment.

More Answers (0)

Products

Release

R2022a

Asked:

on 23 Jun 2023

Commented:

on 25 Jun 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!