-
Notifications
You must be signed in to change notification settings - Fork 1
/
SemiLogXPlot.m
48 lines (43 loc) · 1.32 KB
/
SemiLogXPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
%loglog plot
function SemiLogXPlot(m_data,marker,color,min_cut,max_cut,unit_bins)
if nargin < 6
unit_bins=20;
end
if nargin < 5
max_cut = 9999999;
end
if nargin <4
min_cut =0.0000001;
end
index=find(m_data>min_cut&m_data<max_cut);
m_data=m_data(index);
max_data=max(m_data);
min_data=min(m_data);
max_order=ceil(log10(max_data))
min_order=floor(log10(min_data))
order_range=max_order-min_order;
Nbins=zeros(1,order_range*unit_bins+1);
[m,n]=size(m_data);
min_order_data=10^min_order;
for ii=1:m
Nbins(1,floor(log10(m_data(ii)/min_order_data)*unit_bins)+1)=Nbins(1,floor(log10(m_data(ii)/min_order_data)*unit_bins)+1)+1;
end
Nbins_sum=sum(Nbins');
Nbins=Nbins./Nbins_sum;
x=[];
for i=1:size(Nbins,2)
x(i)=10^(min_order+i/unit_bins);
if i>1
Nbins(i)=Nbins(i)/(x(i)-x(i-1));
else
Nbins(i)=Nbins(i)/(x(i)-0);
end
end
index=find(Nbins>0);
polyfit(log10(x(index)),log10(Nbins(index)),1)
%loglog(x(1:end),Nbins(1:end),[color,marker],'MarkerEdgeColor',color,'MarkerSize',5);
semilogx(x(1:end),Nbins(1:end),[color,marker],'MarkerEdgeColor',color,'MarkerSize',8);
set(gca,'FontName','Times New Roman','FontSize',15)
xlabel('x','FontName','Times New Roman','FontSize',15)
ylabel('P(x)','FontName','Times New Roman','FontSize',15)
xlim([10^min_order,10^max_order])