Can I automatically find True north-based azimuths based on certain value of an azimuth from a refference point ?
Let's say if I have a value of 90 the result will be East, I have a value of 25 the result will be North-northeast.
I could do a function but maybe there's more easier methodes.
Thank you!

 Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 22 de Mayo de 2022

0 votos

Your question doesn't make much sense, sure you can do that - but that would be more of "establishing" your azimuth-convention. If you are thinking of calculating the azimuth clockwise from North to a point [x,y] from a point [x0,y0]. Then atan2 should be your friend:
phi = atan2(x0-x,y0-y);
Or atan2d if you directly want the angle in degrees - which I've found to be a dangerous habit to use, it is in my experience strongly preferable to have all angles in radians and convert to degrees when displaying.
HTH

5 comentarios

Cristian Martin
Cristian Martin el 22 de Mayo de 2022
Bjorn, I mean Cardinal points, sorry. Based of an specified azimuth. If the az=90 result be East.
Bjorn Gustavsson
Bjorn Gustavsson el 22 de Mayo de 2022
What is your problem? Do you want to convert a set of azimuth-angles relative to some cardinal direction to an azimuth clockwise from north?
Cristian Martin
Cristian Martin el 22 de Mayo de 2022
I think my question was not so clear, excuse me.
Let's say I have:
Coord 1:
lat1 = value 1 in dm;
lon1 = value 2 in dm;
Coord 2:
lat2 = value 3 in dm;
lon2 = value 4 in dm;
The azimut from coord 1 to coord 2 is 45 degree. Matlab has a command for displaying cardinal point in this case Northeast ?
I have found something but I don't know how to adapt it in my case
directionValues = 0:22.5:337.5;
directionNames = {'N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSV','SV','VSV','V','VNV','NV','NNV'};
directionValues(strcmp(directionNames,'V'));
If you want to display the label from directionNames with the directionValues closest to an arbitrary angle, phi, you only have to determine the "best matching direction". You can for example do this:
dl2 = ((cosd(phi)-cosd(directionValues)).^2 + ...
(sind(phi)-sind(directionValues)).^2); % should be robust to wrap-arounds
[dl,idx_best] = min(dl2);
disp(directionNames);
HTH
Cristian Martin
Cristian Martin el 22 de Mayo de 2022
Thanks Bjorn !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2015a

Preguntada:

el 22 de Mayo de 2022

Comentada:

el 22 de Mayo de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by