Matlab program to find effect of Noise on Message Signal when Amplitude and Phase are change at every point, and also find at which point maximum noise is added.
Matlab code
clc;
close all;
clear all;
t=0:.001:1/f;% Define time axis.
A=1+rand(1,length(t));% Message Signal Amplitude
Phase=2*pi*rand(1,length(t));% Message Signal Phase
snr=20; % Assume Signal to noise ratio is 20 db.
for i=1:length(t)
m=A(i)*sin(2*pi*f*t+Phase(i)); % Message Signal
end;
n=awgn(m,snr); % Adds White Gaussian Noise to signal m.
w=n-m; % Difference b/w Noise Added Signal & Message Signal.
z=abs(w); % Converting -ve value of w in to +ve value.
y=max(z);% Find maximum value of z.
x=find(z==y); % Returns a list of the positions (indices) of z satisfying the given condition.
plot(t,m,'--');
hold on;
plot(t,n,'r');
stem(t(x),n(x),'g','.');
text(t(x)+.005,n(x),'Maximum Noise');
xlabel('Time-->');
ylabel('Amplitude-->');
title('Effect of Noise on Message Signal');
legend('Message Signal without Noise','Message Signal with Noise');
No comments:
Post a Comment