Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
matlab中裂纹的正态分布_Matlab_Matlab Figure - Fatal编程技术网

matlab中裂纹的正态分布

matlab中裂纹的正态分布,matlab,matlab-figure,Matlab,Matlab Figure,根据以下脚本,裂缝随机分布在岩层中,尺寸为200x200。根据脚本估计裂纹密度,并绘制裂纹密度和最终裂纹长度的直方图。我的任务不是随机分布裂缝,而是概率分布为正态分布。我已经在matlab中编辑了rand代码(randn,它通常分配随机数)。因为在使用正整数和负整数的matlab正态分布中,使用abs代码消除负整数,abs代码通过将负整数转换为正整数仅使用绝对整数,因为我不能有负裂纹 t = 0.2 + 0.1.*randn(L,L); r = abs(t); z = r<porosity

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

t = 0.2 + 0.1.*randn(L,L);
r = abs(t);
z = r<porosity;
t=0.2+0.1.*randn(L,L);
r=abs(t);
z=r
%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)