Matlab toolbox for handling coordinates in the British Ordnance Survey map projection
[lon, lat] = OS.convertAndTransform(219055,656439)
% lon =
% -4.88586469639923
% lat =
% 55.767345888062
[easting, northing] = OS.convertAndTransform(-4.88586469639923, 55.767345888062)
% easting =
% 219055.000044897
% northing =
% 656438.999978426
In many cases the use of lat/lon versus easting/northing can be detected automatically by the magnitude of the numbers used. This can be explicitly controlled though by using the from and to optional arguments
[lon, lat] = OS.convertAndTransform(219055,656439, 'from', 'EN', 'to', 'LL')
[easting, northing] = OS.convertAndTransform(-4.88586469639923, 55.767345888062, 'from', 'LL', 'to', 'EN')
ngr = OS.num2ngr(219055,656439)
% ngrCode =
% NS 19055 56439
The same thing can also be achieved with separate outputs
[ngrCode, ngrEasting, ngrNorthing] = OS.num2ngr(219055,656439)
% ngrCode =
% NS
% ngrEasting =
% 19055
% ngrNorthing =
% 56439
[e,n] = OS.ngr2num('NS', '19055', '56439')
% e =
% 219055
% n =
% 656439
The same thing can be achieved by passing in a single string
[e,n] = OS.ngr2num('NS 19055 56439')
% e =
% 219055
% n =
% 656439