
%  signed_Tresca.m  ver 1.1  by Tom Irvine

function[str]=signed_Tresca(pstress)

ss=size(pstress);

nc=ss(2);

if(nc==2 || nc==3)
else
    errordlg(' Column error');
    return;
end

[polarity]=signed_stress_polarity(pstress);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

s1=pstress(:,1);
s2=pstress(:,2); 

n=length(s1);
sigma_tres=zeros(n,1);

if(nc==2)
        
    for i=1:n
        sigma_tres(i)=max([ abs(s1(i)-s2(i)) , abs(s1(i)) , abs(s2(i)) ]);
    end    
        
end

if(nc==3)
    s3=pstress(:,3);   

    for i=1:n
        sigma_tres(i)=max([ abs(s1(i)-s2(i)) , abs(s2(i)-s3(i)) , abs(s3(i)-s1(i)) ]);
    end 
    
end

pstress(1:10,:)


str=polarity.*sigma_tres; 