how to convert wind direction to degrees?

Illustration
Lilya - 2022-01-17T13:59:39+00:00
Question: how to convert wind direction to degrees?

Hi all,   I am working with wind speed and direction but the last is in form of compass, thus it required to convert it to degrees. could anyone kindly help me?   thank you in advance.

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

You could store the names and values in arrays and look up the angle corresponding to the matching name.

 

directionValues = 0:22.5:337.5
directionNames = {'N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'};

directionValues(strcmp(directionNames,'NNW'))

Better yet, put that in an anonymous function

compass2degree = @(dirName) directionValues(strcmp(directionNames,dirName));

compass2degree('ESE')

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!