-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorCalculation.m
More file actions
26 lines (22 loc) · 978 Bytes
/
Copy patherrorCalculation.m
File metadata and controls
26 lines (22 loc) · 978 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
function y = errorCalculation(expected,actual)
% This is a function to calculate the expected error. It takes in 2
% vectors: the expected result and the actual result and calculates the
% percent error of the actual compared to the expected. It is important
% that both vetors start the same.
errorCounter = 0; % This is a counter
% If the expected vector is longer than the actual vector this function
% will not work and will return this error.
if length(expected) > length(actual)
error('expected is longer than actual')
end
% For every wrong value that the vectors do not match on the counter
% will increase by 1.
for i = 1:length(expected)
if expected(i) ~= actual(i)
errorCounter = errorCounter + 1;
end
end
% Calculate percent error and produce result of function.
errorRate = errorCounter/length(expected);
y = errorRate;
end