matlab中裂缝的正态分布

时间:2017-04-03 21:23:15

标签: matlab matlab-figure

从下面的脚本中,裂缝在岩层中随机分布,尺寸为200x200。根据脚本估算裂缝密度,绘制裂缝密度和最终裂缝长度的直方图。我的任务是不是随机分布裂缝,而是按正态分布概率分布裂缝。我已经在matlab中编辑了rand代码(randn,它通常分配随机数)。由于在使用正整数和负整数的matlab正态分布中,使用绝对整数消除了负整数,通过将负整数转换为正整数,因为我不能有负的裂缝。

t = 0.2 + 0.1.*randn(L,L);
r = abs(t);
z = r<porosity;

0.2和0.1是我制作钟形分布的平均值和标准差。对于正态分布,图形应该是钟形的,但是从编辑过的脚本中我得到钟形的一半,并且它不像通常分布的那样均匀分布。是否有任何方法可以获得钟形的正常分布? 在此先感谢您的帮助! 这是脚本:

%Finding Crack Density for selected P, N times
global X_Tips Y_Tips
Cycles = 1000;
Crack_Density_Values = zeros(1,Cycles);
%In the furutre porosite will be taken from a calcualted range for some
%dimension L 
critical_crack_Length = 12;
L = 200;
porosity = 0.041;

 %Applying Temperature Gradient
v = 0:1:L;
[X,Y] = meshgrid(v);
Z =  10000 + (X.^2 + Y.^2);
[px,py] = gradient(Z,1);
for i10 = 1:Cycles
    r = rand(L,L);
    z = r<porosity;
    %Assigns a unique ID to each individual void. num tells us how many void
    %exist.
    [lw, num] = bwlabel(z,8);
    %Before crack propagation 
    img = label2rgb(lw);
%Go through each crack and propagate until length of one crack == ccl
%For this exmaple, assume critical crack length = 12 sqaures 
    Number_of_cracks = num;
    %Find size of each crack first, gives me amount of increments needed for
    %one crack to reach critical crack length
    critical_crack_length = 12; %Assumed for this example. 
    Crack_Lengths = zeros(1,num); 
    for i = 1:Number_of_cracks
        id = i;
        %finding coordinates of crack
        [r,c] = find(lw==id);
        rc = [r c]; %[x,y]
        rc_size = size(rc);
        Crack_Length = max(rc_size);
        Crack_Lengths(i) = Crack_Length;
    end 
    %Finding minium increment needed to reach CCL
    max_crack_length = max(Crack_Lengths);
    Increments = critical_crack_length - max_crack_length;
    %I've now got my crack increment length
    %now we to calculate crack density after failure. 
    %Getting Half Crack Lengths (Crack_Lengths does not update so I can just go
    %through that and add the increment/
    Final_Crack_Lengths = Crack_Lengths + Increments;
    %Half Crack Lengths
    Half_Crack_Length = Final_Crack_Lengths ./ 2;
    Volume = L*L*1; %unit thickness
    Crack_Density = (sum((Half_Crack_Length.^3)))/ Volume;
    Crack_Density_Values(i10) = Crack_Density;
end
%Hisogram for data 
figure(1)
plot(Crack_Density_Values,'*')
figure(2)
nbins = 5
hist(Final_Crack_Lengths, nbins)

0 个答案:

没有答案