function [azimut_smeru] =	Vykresleni_M	(IMU)

b = size(IMU,1);
a=1;
c=3;

while c < b+1                                                               % separace dat z magnetometru
    datam1(a,1) = IMU(c,1);
    datam1(a,2) = IMU(c,2);
    datam1(a,3) = IMU(c,3);
a=a+1;
c=c+3;
end

% figure(4);
% compass(datam1(:,1),datam1(:,2)),'g';
% hold on;

ggg=sqrt((datam1(:,1)).^2+(datam1(:,2)).^2);                                % prevod vektoru na jednotkovy vektor
datam2(:,1) = datam1(:,1)./ggg;
datam2(:,2) = datam1(:,2)./ggg;

b = size(datam2,1);
c=1;
while c < b+1                                                               %korekce kompasu vuci INS 15°
azimut(c,1)=(atan2(datam2(c,2),datam2(c,1)))+(pi/12);  
rho =ones(size(azimut,1),1);
c=c+1;
end
[datam2(:,1),datam2(:,2)] = pol2cart(azimut(:,1),rho);                      %prevod z polernich souradnic do kartezkych 


figure(6);
compass(datam2(:,1),datam2(:,2),'b');
title('Jednotkovy vektor severu vuci osam INS')                             % nazev grafu
hold on;

b = size(datam2,1);
c=1;
while c < b+1
azimut(c,1)= [0];
azimut(c,2)=(atan2(datam2(c,2),datam2(c,1)));                               %prevod z kartezkych souradnic do polarnich     



if datam2(c,1) >= 0 && datam2(c,2) >= 0                                                         %urcovani smeru pohybu
    azimut_smeru(c,1) = pi/2+azimut(c,2);
end
if datam2(c,1) >= 0 && datam2(c,2) < 0                                                         %urcovani smeru pohybu
    azimut_smeru(c,1) = pi/2-azimut(c,2);
end
if datam2(c,1) < 0 && datam2(c,2) <= 0                                                         %urcovani smeru pohybu
    azimut_smeru(c,1) = -(pi)-(pi/2+(azimut(c,2)));
end
if datam2(c,1) < 0 && datam2(c,2) > 0                                                         %urcovani smeru pohybu
    azimut_smeru(c,1) = -(pi)+(azimut(c,2)-pi/2);
end

c=c+1;
end


rho =ones(size(azimut_smeru,1),1);                                  
[datam(:,1),datam(:,2)] = pol2cart(azimut_smeru(:,1),rho);                  %prevod z polernich souradnic do kartezkych 
figure(6);
compass(datam(:,1),datam(:,2),'r');
hold off;

end 