-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallHits.m
More file actions
28 lines (26 loc) · 1020 Bytes
/
wallHits.m
File metadata and controls
28 lines (26 loc) · 1020 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
%**************************************************************************
% wallHits.m
% Adam Hill
% February 11, 2008
%
% Function to calculate how many impulses have hit a wall.
%
% Input arguments: n = current index number
% Ouput values: wall_1, wall_2
%
%**************************************************************************
function [wall_1 wall_2] = wallHits(n)
% Find the umber of times each wall is encountered
if n < 0
wall_1 = ceil(abs(n)/2); % how many wall_1 hits
wall_2 = floor(abs(n)/2); % how many wall_2 hits
elseif n > 0
wall_1 = floor(n/2); % how many wall_1 hits
wall_2 = ceil(n/2); % how many wall_2 hits
else
wall_1 = 0; % direct sound
wall_2 = 0; % direct sound
end
%**************************************************************************
% END OF FUNCTION
%**************************************************************************