-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom_noise.m
More file actions
48 lines (36 loc) · 970 Bytes
/
Random_noise.m
File metadata and controls
48 lines (36 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
close all
clc;
% creating a Signal
t =0:500;
signal=zeros(1,501);
spikeAt = 50;
signal(spikeAt)= 10;
% creating a Random Noise
noise=randn(1,501);
% addition of Noise in Signal and shifting(lagging) of signal
shift=100;
noisey_signal=circshift(signal+noise,shift);
% finding Correlation of Original Signal and Noisey Signal
[c,lag] = xcorr(signal,noisey_signal);
M = islocalmax(c,MinProminence=max(c));
maxima = islocalmax(noisey_signal,'MinProminence',max(noisey_signal));
subplot(4,1,1);
plot(t,signal,'g');
xlabel('time')
ylabel('Amplitude')
title('Original Signal');
subplot(4,1,2)
plot(t,noise,'r');
xlabel('time')
ylabel('Noise value')
title('Noise');
subplot(4,1,3)
plot(t,noisey_signal,t(maxima),noisey_signal(maxima),'r*');
xlabel('time')
ylabel('Amplitude')
title('Noisey Signal');
subplot(4,1,4)
plot(lag,c,'g',lag(M),c(M),'r*');
xlabel('time lag')
ylabel('Correlation value')
title('Correlation');