echo off; clear; format compact;
%Priklad 2: 
 
alfa=          60; %stupen
d_AB=         100; %m
m_d=         0.02; %m
m_alfa=     0.002; %g

'Priklad 2.1:'

%Zavedení soøadnic bodu A a prevod uhlu na obloukovou míru
yA = 0;
xA = 0;
rad = pi / 180;
alfa =  alfa * rad;
m_alfa = m_alfa * rad;

%Souradnice bodu B a C
yB = d_AB * sin (alfa)
xB = d_AB * cos (alfa)

%Pro ilustraci
X = [ alfa
      d_AB ];   
Y = [ yB
      xB ];

%Kovariancni matice sigma XX
Sigma_XX = [ m_alfa^2 0
             0        m_d^2];

%Matice parcialnich derivaci A
A = zeros(2);

syms x
A(1,1) = subs( diff(d_AB * sin (x)),   x, alfa);
A(1,2) = subs( diff(x * sin (alfa)),   x, d_AB);

A(2,1) = subs( diff(d_AB * cos (x)),   x, alfa);
A(2,2) = subs( diff(x * cos (alfa)),   x, d_AB);

%Kovariancni matice souradnic bodu B a C
Sigma_B = A * Sigma_XX * A'


m_yB = sqrt ( Sigma_B )
m_xB = sqrt ( Sigma_B )

m_yB = sqrt ( A(1,:) * Sigma_XX * A(1,:)' )
m_xB = sqrt ( A(2,:) * Sigma_XX * A(2,:)' )
