function eta = PowerLaw_fitting_method_and_plotting(fig_num,x,y)

%---power law method are used to fit the x, y data
%-- Power Law distribution---  --- Outputs: eta

%---THEN, a loglog plot is made on figure(fig_num)

%---start fitting the data---
%---Power law distribution---
% x=MCD_norm;
% y=N_L;
F_powerlaw0=@(epsilong,x)(epsilong(1)*(x.^(-1*epsilong(2))));
epsilong0 = [min(x) 1];
[epsilong,resnorm,residual,exitflag,output,~,jacobian] = lsqcurvefit(F_powerlaw0,epsilong0,x,y);
x_plot=[min(x):0.001:max(x)*1.5];
y_fit_powerlaw0 = (epsilong(1)*(x_plot.^(-1*epsilong(2))));
figure(fig_num)
hold on

loglog(x_plot,y_fit_powerlaw0,'k','LineWidth',2)
eta=epsilong;

set(gcf, 'Color','w')
set(gca,'Box','off','Fontsize',18)
xlabel(gca,'$L/h$ [-]','Fontsize',25,'interpreter','Latex');
ylabel(gca,'$N(>=L)/N_{total}$','Fontsize',25,'interpreter','Latex');
legend(gca,{'Test data','Power-Law'},'Box','on')
legend('location','southwest')

axis tight



end