Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
num2direction.m
Go to the documentation of this file.
1% =========================================================================== %
2%> @brief convert a number to a direction
3%>
4%> @param num number to convert
5%>
6%> @retval dir direction (positive, negative)
7%>
8%> @code
9%> dir = num2direction(1) % returns "positive"
10%> dir = num2direction(-1) % returns "negative"
11%> @endcode
12%>
13%> @copyright see the file @ref LICENSE in the root directory of the repository
14% =========================================================================== %
15function dir = num2direction(num)
16
17arguments
18 num (1,1) double
19end
20
21num = round(num);
22
23if num > 0
24 dir = "positive";
25elseif num < 0
26 dir = "negative";
27else
28 error("The number %d does not correspond to a direction", num)
29end
30
31end
function num2direction(in num)
convert a number to a direction