-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApr1_rangetest.m
56 lines (48 loc) · 1.07 KB
/
Apr1_rangetest.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
clc; clear all;
v = 15; %m/s, speed of car
h = 0.6; %m, height of sensor
theta = 15*(pi/180); %angle of sensor
x = linspace(1,100,1001);
ground = zeros(1,1001);
for i = 300:600
ground(i) = -0.3;
end
readings = zeros(1,1001);
for i = 1:970
height = h + ground(i);
j = i;
while true
deltax = x(j+1) - x(j);
deltay = deltax*tan(theta);
height = height - deltay;
if height <= ground(j)
readings(i) = sqrt((h - height)^2 + (x(j) - x(i))^2);
break
end
j = j + 1;
end
end
d = h/sin(theta);
horiz = h/tan(theta);
calcs = zeros(1,1001);
%data = readings - d;
data = readings;
data = data * sin(15*pi/180);
data = data - 0.6;
%for i = 1:970
%
%end
figure(1)
plot(x,ground)
title('Ground Level')
xlabel('Distance (m)')
ylabel('Depth (m)')
ylim([-0.5 0.5])
figure(2)
plot(x,readings)
figure(3)
plot(x,data)
xlim([0 95])
title('Sensor Interpretation of Dip and Rise in Ground')
xlabel('Distance (m)')
ylabel('Upcoming Change in Ground Height (m)')