 % 2 Layer Sediemnt correction with 500m boundary and 1.6 & 1.9 mg/m3
LMSC = zeros(1801,3601);

% Making the above correction matrix same like M_Sed with NaNs
 %Ref: http://www.mathworks.com/matlabcentral/answers/63997
idx=arrayfun(@sign ,LMSC(:).*M_Sed(:));    
LMSC(idx==1 | isnan(idx))=nan;

% Applying multi layer Check

% Individual Densities of each layers 100 m thick
RhoS = [1.67,1.74,1.81,1.88,1.95,2.02,2.09,2.16,2.23,2.3,2.37,2.44,2.51,2.58,2.65,2.72];

%-----Ref:http://www.mathworks.com/matlabcentral/newsreader/view_thread/98163
%z = 1.7
%[x,y]=deal(fix(z), z-fix(z))
% result: x =1 and y =0.7000

%get the no of whole layers
%(deal(fix(LMSC(:)/100)))
lno = zeros(1801,3601);
lno(:)=(deal(fix(M_Sed(:)/100)));

RhoSw = zeros(1801,3601);
RhoSw(:)=RhoS(1:lno(:));
% the expression is (1/ts)*(100*sum of lno no of
% densities)+(ts-(lno*100))*density of lno+1)
LMSC(:) = ((100*sum(RhoS(1:(deal(fix(M_Sed(:)/100))))))+((M_Sed(:) - ((deal(fix(M_Sed(:)/100)))*100))*RhoS((deal(fix(M_Sed(:)/100)))+1)))/M_Sed(:);

LMSC(:) = (100*sum(RhoSw(:)))/M_Sed(:);

+((M_Sed(:) - (lno(:)*100))*RhoS(lno(:)+1)))/M_Sed(:);

%Isostatically corrected Plate Model Bathymetry using Muller Sediment 
%Thickness  & 2 Layer Correction
PM_M_2LSC = zeros(1801,3601);
PM_M_2LSC = PM(:) +  LMSC(:);

%Isostatically corrected Plate Model Bathymetry using Divine 2003 Sediment 
% Thickness  & 2 Layer Correction
PM_ST_2LSC = zeros(1801,3601);
PM_ST_2LSC = PM(:) +  LMSC(:);
