% This function convert the stress in Cartesian co-ordinates into cylindrical co-ordinate
% Inputs:
    % Carstr- the stress in Cartesian co-ordinates.
    % theta- azimuth angle.
% Outputs:
    % Cylinstr- the stress in cylindrical co-ordinates.
function Cylinstr=Cartocylin(Carstr,theta)
matrix=[cos(theta)^2 sin(theta)^2 0 0 0 sin(2*theta);
        sin(theta)^2 cos(theta)^2 0 0 0 -sin(2*theta);
        0 0 1 0 0 0;
        0 0 0 cos(theta) -sin(theta) 0;
        0 0 0 sin(theta) cos(theta) 0;
        -sin(2*theta)/2 sin(2*theta)/2 0 0 0 cos(2*theta);];
Cylinstr=matrix*Carstr';