Chan_Loss = 1;
y_mod_am_chan = y_am_mod/Chan_Loss; % signal after channel attenuation/loss
% a_int_sig = 5e-2; % amplitude of interference signals
% f_int_sig = [10e3, 20e3, 25e3, 32e3, 40e3]; % frequencies of interference signals
% int_sig = a_int_sig*sin(2*pi*f_int_sig(1)*time');
% for f_int = f_int_sig(2:end)
% int_sig = int_sig + a_int_sig*sin(2*pi*f_int*time');
% end
signal_power = std(y_mod_am_chan); % Signal Power
noise_power = 0.01*signal_power; % noise power
noise_sig = randn(no_of_pnts, 1)*noise_power; % noise signal generated based on normal distribution
y_mod_am_int = y_mod_am_chan; % received signal with interference signals
You need to geneterate the same plots for all noise powers (0.01, 0.1, 0.5, and 1 times the received signal power at the receiver).
Basically you need to change the coefficient value in
noise_power = 0.01*signal_power; % noise power
line in your channel section.

 Accepted Answer

If understood correctly, what you are trying to attain is to generate a few different noise powers from the given signal. If so, then
t = (0:0.05:10)';
x = sin(t);
SNR = [0.01, 0.05, 0.1, 1, 10, 50];
LC = 'kbmgck';
for ii = 1:numel(SNR)
% White noise is generated with awgn():
y_noise = awgn(x,SNR(ii), 'Measured'); % Assumes that the input signal power value in dBW
figure(ii)
plot(t,x, 'r',"LineWidth",2, "DisplayName",'Measured data')
hold on
plot(t,y_noise, LC(ii), 'LineWidth', 1.25, "DisplayName",'Noise added signal')
title(['SNR Level is ' num2str(SNR(ii)) ' dB'])
legend('Show')
end

6 Comments

Matt
Matt on 6 Jan 2024
That is beautiful. Thank you so much.
Matt
Matt on 7 Jan 2024
On the line for ii = 1:numel(SNR) it comes up with the warning: Negative data ignored.
Most welcome! Glad to be of some help :) Please vote for Thumbs UP :)
Check your typed in code carefully. It should not produce any warning. Note that numel() does not care about negative or positive values. It counts how many elements in the array.
Matt
Matt on 7 Jan 2024
@Sulaymon Eshkabilov it still does the same issue
Matt
Matt on 7 Jan 2024
@Sulaymon Eshkabilov nevermind, it completely works :)

Sign in to comment.

More Answers (0)

Categories

Asked:

on 6 Jan 2024

Commented:

on 7 Jan 2024

Community Treasure Hunt

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

Start Hunting!