Tag Archives: matlab

Maidenhead Locator System

Have you ever wondered how the so-called QTH Locator or WW locator is calculated and what is behind it?

Many HAMs and radioamateurs use it but ask them where their locator came from and not many can tell you. There are plenty of web based applications which overlay Google maps with a locator grid and many of them provide a calculator for conversion from other geographic coordinates to Maidenhead Locator System.

clear all;
close all;
clc;

m = mobiledev();
m.Logging = 1;
pause(2)

lat = 50.2727514;
lon = 14.2518494;

alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S'];

locator = [];
len = 4;

lon = lon + 180;
lat = lat + 90;

lon = lon / 20;
lat = lat / 10;

for i = 1:len
    
    lon_tmp = floor(lon);
    lat_tmp = floor(lat);
    
    if mod(i,2) == 0
        
        locator = [locator int2str(lon_tmp) int2str(lat_tmp)];
        lon = (lon - lon_tmp) * 24;
        lat = (lat - lat_tmp) * 24;
        
    else
        
        locator = [locator alphabet(lon_tmp+1) alphabet(lat_tmp+1)];
        lon = (lon - lon_tmp) * 10;
        lat = (lat - lat_tmp) * 10;
        
    end
end

locator

Corresponding output:

locator =

    'JO70DG05'

And the most amazing aspect is executing .m files on your iPhone. The disadvantage is that an internet connection is necessary for computing via the application.