function [output] = decode_status (input)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% convert message to binary representations

% convert to binary
bin=dec2bin(input);
bin=['00000000',bin];
bin_value=bin(:,end-7:end);

% get flag fields
decode{1}=bin2dec(bin_value(6:8));
decode{2}=bin2dec(bin_value(5));
decode{3}=bin2dec(bin_value(4));
decode{4}=bin2dec(bin_value(3));
decode{5}=bin2dec(bin_value(2));
decode{6}=bin2dec(bin_value(1));

% determine position solution type
if ((decode{1}<=2)&(decode{2}==0)&(decode{3}==0)&(decode{5}==0))
   output=0;       % no GPS
elseif ((decode{1}==3)&(decode{2}==0)&(decode{3}==0)&(decode{5}==0))
   output=0.5;     % auto (2-D)
elseif ((decode{1}==4)&(decode{2}==0)&(decode{3}==0)&(decode{5}==0))
   output=1;       % auto
elseif ((decode{1}==3)&(decode{2}==0)&(decode{3}==1)&(decode{5}==0))
   output=1.5;     % DGPS (2-D)
elseif ((decode{1}==4)&(decode{2}==0)&(decode{3}==1)&(decode{5}==0))
   output=2;       % DGPS
elseif ((decode{1}==4)&(decode{2}==0)&(decode{3}==0)&(decode{5}==1))
   output=3;       % float
elseif ((decode{1}==4)&(decode{2}==1)&(decode{3}==0)&(decode{5}==1))
   output=4;       % fixed
else
   output=0;
   fprintf('  Unknown Position Flag (value %.0f) (flag %s)\n',input,bin_value);
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
return;
