For matlab's notion of azimuth (i.e. N=0, W=270, S=180, E=90 that runs clockwise) the answer's simple. For azimuth $a$, compute $h = 450 - a$; if $h > 360$, return $h - 360$; otherwise return $h$.
For the remainder of this answer, I'm going to assume that by "Azimuth angles" you mean something like 135E or 37W, which mean (respectively), "135 degrees east of north" (or "clockwise from north") and "37 degrees west of north (or "counterclockwise from north").
Here's a general rule, assuming that for an azimuth like 47E, we say that the number, $n$, is $47$, and the "name" is "E".
If the name on the azimuth angle is "W", simply return $n + 90$
If the name is "E" ...
a. If $n \le 90$, return $90 - n$.
b. Otherwise, return $450- n$
As examples:
40W ---> 40+90 = 130 degrees [Rule 1]
150W ---> 150 + 90 = 240 degrees [Rule 1]
40E ---> 90 - 40 = 50 degrees [Rule 2a]
120E ---> 450-120 = 330 degrees [Rule 2b]
It's worth checking the cardinal points, too:
90E ---> (90-90) = 0 [Rule 2a]
0E ---> 90-0 = 90 [Rule 2a]
90W ---> 90+90 = 180 [Rule 1]
The only remaining question is what to do with 180E or 180W. You'll discover that both paths (Rule 1, or rule 2b) in my formula lead to the answer "270", which is what you want.
If $\theta$ is your original angle, then $(-\theta + 90^{\circ}) \bmod 360^{\circ}$ will work. The negative on $\theta$ deals with the fact that we are changing from counterclockwise to clockwise. The $+90^{\circ}$ deals with the offset of ninety degrees. And lastly we need to mod by $360^{\circ}$ to keep our angle in the desired range $[0^{\circ},360^{\circ}]$.
Best Answer
Here is a way to get a direction angle for your line, where $0\le \theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.
$$\theta = \begin{cases} 90°-\dfrac{180°}{\pi}\cdot\tan^{-1}\left(\dfrac{y_2-y_1}{x_2-x_1}\right), & \text{if }x_1\ne x_2 \\[2ex] 0°, & \text{if }x_1=x_2 \end{cases} $$
Here's the explanation:
There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.
You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:
And here is what the angle looks like on a graph:
You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.
As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.
My formula gives values $0°<\theta<90°$ for lines with positive slope and values $90°<\theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.
$$\theta = 90°-\dfrac{180°}{\pi}\cdot\operatorname{atan2}\left(x_2-x_1,y_2-y_1\right)$$
This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)