function x = trojmat(A,b)
% x = reseni trojuhelnikove matice A s pravou stranou b
    s = size(A);
    if (length(s) ~=2 || s(1) ~= s(2) || s(1) ~= length(b))
        disp('Zadejte ctvercovou matici A a vektor b o stejnem rozmeru');
        return;
    end
    n = s(1); % rozmer matice
    x = 0*b;
    for k = n:-1:1
        soucet = 0;
        for j = k+1:n;
            soucet = soucet + A(k,j)*x(j);
        end
        x(k) = (b(k) - soucet)/A(k,k);
    end
end