function[score] = LCS2(shape1,shape2)
[elem,index] = min(shape1);
minsortA = circshift(shape1,[0,size(shape1,2)-index+1]);
[elem,index] = min(shape2);
minsortB = circshift(shape2,[0,size(shape2,2)-index+1]);
%number of max spaces we can use to match the 2 patterns
mSize = max([size(shape1,2),size(shape2,2)]);
shapeA=zeros(1,mSize);
shapeA(1,1:size(shape1,2))=minsortA;
shapeB=zeros(1,mSize);
shapeB(1,1:size(shape2,2))=minsortB;
matrix = zeros(mSize+1,mSize+1);

 for i=2:size(matrix,1)
      for j=2:size(matrix,2)
            A = shapeA(i-1);
            B = shapeB(j-1);            
            diff = abs(A-B);
            %distance = abs(((j-1)/size(shape2,2))-((i-1)/size(shape1,2)));
            if(A==0 || B==0)
               %score = 0-distance;
               score=0;
            else
                score = (abs((90-diff))/90);
                
            end
            best = max([score+matrix(i-1,j-1),matrix(i-1,j),matrix(i,j-1)]);
            matrix(i,j)=best;
        end    
 end


%return score averaged by length of shape contour features list
matrix;
score = max(matrix(size(matrix,1),:,size(matrix,3)))/min([size(shape1,2),size(shape2,2)]);


        
        

