Arrays 在matlab中创建三维矩阵

Arrays 在matlab中创建三维矩阵,arrays,matlab,loops,matrix,multidimensional-array,Arrays,Matlab,Loops,Matrix,Multidimensional Array,我想画出安全系数(FS,某个地区滑坡风险的量化)的时间演变图 计算如下: effcohesion=0; rootcohesion=0; gammat=12.9E3; gammaw=9810; c=0; deltac=0; m=0.5; z=2.5; phi=16; slope=rand(20,20)*30 % slope of a gridpoint in area Strength = c + deltac + (gammat - gammaw.*m).*z.*(cosd(slo

我想画出安全系数(FS,某个地区滑坡风险的量化)的时间演变图

计算如下:

effcohesion=0;
rootcohesion=0;
gammat=12.9E3;
gammaw=9810;
c=0;
deltac=0;
m=0.5;
z=2.5;
phi=16;
slope=rand(20,20)*30       % slope of a gridpoint in area

Strength = c + deltac + (gammat - gammaw.*m).*z.*(cosd(slope).^2);
Stress = gammat.*z.*(sind(slope)).*(cosd(slope));
Part = tand(phi);
FS2 = (Strength./Stress).*(Part)
现在。m的值(=地下水位的高度,它决定了FS)全年都在变化,因此不是恒定的。我有一个包含降水、蒸发等数据的文件,但为了不太复杂,我这里假设m只是一年中某一天的函数:

mnew=zeros(365,1);
for t=1:365
mnew(t)=(m+t)/150;
end
我现在有一个20x20点的数据集,其中m=0.5(=FS2)和一个文件,其中m在这一年(=mnew)中的演变

我现在如何创建一个3D矩阵,其中(1)存储FS的空间变化(因此,20x20矩阵上的FS值)和(2)FS在一年中随m的变化的时间演变。最后,我想要一个矩阵,其中包含FS的空间和时间演化

第1层=第1天所有20x20点的FS

第2层=第2天所有20x20点的FS

等等

有人能帮我吗

提前谢谢

将“3D矩阵”更恰当地称为秩3数组。为此,只需将您的
FS2
计算粘贴到时间循环中即可。不要使用
m
,而是使用适当的
mnew
来计算
FS2
。然后将
FS3
(秩3数组)的层设置为
FS2

然后,第1层(第1天)由
FS3(:,:,1)
给出,第2层由
FS3(:,:,2)
给出,等等

m0=0.5;

% Sizes of array
n1 = 20;
n2 = 20;
n3 = 365;

FS3 = zeros(n1, n2, n3);

mnew=zeros(n3,1);
for t=1:n3

    mnew(t)=(m0+t)/150;

    effcohesion=0;
    rootcohesion=0;
    gammat=12.9E3;
    gammaw=9810;
    c=0;
    deltac=0;

    m = mnew(t);

    z=2.5;
    phi=16;
    slope=rand(n1,n2)*30;       % slope of a gridpoint in area

    Strength = c + deltac + (gammat - gammaw.*m).*z.*(cosd(slope).^2);
    Stress = gammat.*z.*(sind(slope)).*(cosd(slope));
    Part = tand(phi);
    FS2 = (Strength./Stress).*(Part);

    FS3(:,:,t) = FS2;

end