-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNoise.m
67 lines (63 loc) · 1.83 KB
/
Noise.m
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
clc
clear all
close all
%%Noises - Using rand to create a vector of random variables
v = rand(1,10); %vector v of size 10
figure
subplot(2,1,1); %creating a subplot
plot(v); %plot vector
title('plot of vector v of size 10')
ylabel('Amplitude')
xlabel('Number of elements in vector v')
subplot(2,1,2);
hist(v); %use hist to plot approximate pdf
title('Approximate pdf of vector v of size 10')
ylabel('Frequency')
xlabel('Elements in vector v')
v_mean_1 = mean(v) %mean of vector v
v_var_1 = var(v) %variance of vector v
%repeating above vector v of size 10000
v = rand(1,10000);
figure
subplot(2,1,1);
plot(v);
title('plot of vector v of size 10000')
ylabel('Amplitude')
xlabel('Number of elements in vector v')
subplot(2,1,2);
hist(v); %use hist to plot approximate pdf
title('Approximate pdf of vector v of size 10000')
ylabel('Frequency')
xlabel('Elements in vector v')
v_mean_2 = mean(v) %mean of vector v
v_var_2 = var(v) %variance of vector v
%% Using randn() to generate v for size 10
v = randn(1,10);
figure
subplot(2,1,1)
plot(v);
title('plot of vector v of size 10')
ylabel('Amplitude')
xlabel('Number of elements in vector v')
subplot(2,1,2)
hist(v);
title('Approximate pdf of vector v of size 10')
ylabel('Frequency')
xlabel('Elements in vector v')
v_mean_1 = mean(v) %mean of vector v
v_var_1 = var(v) %variance of vector v
%% Repeating using randn() to generate v for size 10000
v = randn(1,10000);
figure
subplot(2,1,1)
plot(v);
title('plot of vector v of size 10000')
ylabel('Amplitude')
xlabel('Number of elements in vector v')
subplot(2,1,2)
hist(v);
title('Approximate pdf of vector v of size 10000')
ylabel('Frequency')
xlabel('Elements in vector v')
v_mean_2 = mean(v) %mean of vector v
v_var_2 = var(v) %variance of vector v