Asking for a code.

6 views (last 30 days)
Sean Audie
Sean Audie on 26 Aug 2022
Answered: Samhitha on 1 Jul 2025
How can I add and plot a gaussian noise difference in this FDM system
% Design and simulation of Frequency Division Multiplexing in MATLAB
clc;
clear all
close all
samples=1000;
% number of users
nos=4;
% modulating signal frequency in Hz
mfreq=[25 50 75 100];
% carrier frequency allocated to the different users in Hz
cfreq=[300 600 900 12000 1500];
% choose frequency deviation
freqdev=10;
% generate modulating signal
t=linspace(0,1000,samples);
%initialize random number generator
rng default
x = sin(t) + 10*rand(size(t));
windowSize = 4;
b = (1/windowSize)*ones(1,windowSize);
a = 1;
parfor i=1:nos
m(i,:)=sin(2*pi*mfreq(1,i)*t)+2*sin(pi*8*t);
end
% Generate the modulated signal
parfor i=1:nos
y(i,:)=fmmod(m(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end
% pass the modulated signal through the channel
ch_op=awgn(sum(y),0,'measured');
% demodulate the received signal at the base station
parfor i=1:nos
z(i,:)=fmdemod(y(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end
% display the transmitted signal and received signal at the base station
% figure
C = {'k','b','r','g','y',[.5 .6 .7],[.8 .2 .6],[.3 .2 .2]};
% Cell array of colors.
for i=1:nos
figure (1)
hold on
plot(y(i,:),'color',C{i});
xlabel('Time index'); ylabel('Amplitude'); title('Signal from different users combined in the channel');
figure
subplot(3,1,1)
plot(m(i,:)) % modulating signal
xlabel('Time index'); ylabel('Amplitude'); title('Modulating Signal from user');
subplot(3,1,2)
plot(y(i,:),'color',C{i}); % modulated signal
xlabel('Time index'); ylabel('Amplitude'); title('Modulated Signal from user');
subplot(3,1,3)
plot(z(i,:),'color',C{i}); % demodulated signal
xlabel('Time index'); ylabel('Amplitude'); title('Demodulated Signal from user at the base station');
end
figure
plot(ch_op) % combination of all modulated signals passed through the channel
xlabel('Time index'); ylabel('Amplitude'); title('Signal after passing through the channel');
y = filter(b,a,x);
figure
plot(t,x)
hold on
plot(t,y)
legend('Input Data','Filtered Data')

Answers (1)

Samhitha
Samhitha on 1 Jul 2025
add Gaussian noise difference in your Frequency Division Multiplexing (FDM) system and plot it, you can use following steps.
  1. Generate clean combined signal (without noise)
  2. Add AWGN (additive white Gaussian noise) to your combined FDM signal.
  3. Compute and plot the difference (the noise added).
Code that you can add in your script:
% Combine all modulated signals (clean FDM signal)
clean_signal = sum(y);
% Pass through channel with AWGN
noisy_signal = awgn(clean_signal, 0, 'measured');
% Compute Gaussian noise difference
noise_diff = noisy_signal - clean_signal;
% Plot the Gaussian noise difference
figure
plot(t, noise_diff)
xlabel('Time index');
ylabel('Amplitude');
title('Gaussian Noise Difference Added to FDM Signal');
For more details, look into following documentation:
Hope this helps!

Products

Community Treasure Hunt

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

Start Hunting!