forked from sheilazpy/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_analysis.m
More file actions
40 lines (40 loc) · 867 Bytes
/
random_analysis.m
File metadata and controls
40 lines (40 loc) · 867 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
function [] = random_analysis(p)
%RANDOM_ANALYSIS Summary of this function goes here
% Detailed explanation goes here
n = 1000;
steps = 1000;
i = 1;
ep = [];
agg = zeros (length (p), steps);
while i <= n
temp = random_walk (p, steps);
agg = agg + abs (temp)/n;
ep (:, i) = temp (:, steps);
i = i + 1;
end
x = [1:1:steps];
figure (1);
plot (x, agg (1, :));
grid on;
figure (2);
hist (ep (1, :));
if length (p) ~= 1
agg = sqrt (sum (agg.^2));
figure (3);
plot (x, agg);
grid on;
figure (4);
hist (sqrt (sum (ep.^2)));
if length (p) <= 3
figure (5);
if length (p) == 1
plot (x, temp);
elseif length (p) == 2
plot (temp (1, :), temp (2, :));
elseif length (p) == 3
plot3 (temp (1, :), temp (2, :), temp (3, :));
end
grid on;
end
end
end