Reputation: 361
I want to plot the temporal evolution of the factor of safety (FS, a quantification for the risk of landslides in a certain area).
This is calculated as follows:
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)
Now. The value of m (= the height of the water table, which determines the FS) varies throughout the year and is thus not constant. I have a file with precipitation, evaporation, etc. data but to make it not too complicated, I here assume that m is just a function of the day of the year:
mnew=zeros(365,1);
for t=1:365
mnew(t)=(m+t)/150;
end
I now have a dataset with FS for 20x20 points where m =0.5 (=FS2) and a file with the evolution of m during the year (= mnew).
How can I now create a 3D matrix where (1) the spatial variation of FS is stored (so the values of FS over the 20x20 matrix) and (2) the temporal evolution of FS in function of m throughout the year. Eventually, I want a matrix that has both the spatial and temporal evolution of FS in it.
Layer 1 = FS at all 20x20 points on day 1
Layer 2 = FS at all 20x20 points on day 2
etc.
Can someone help me?
Thanks in advance!
Upvotes: 2
Views: 134
Reputation: 1051
A "3D matrix" would more properly be called a rank 3 array. To do this, just paste your FS2
calculation inside the time loop. Instead of m
, use the appropriate mnew
to calculate FS2
. Then set that layer of FS3
(the rank 3 array) to FS2
.
Then, layer 1 (day 1) is given by FS3(:,:,1)
, layer 2 by FS3(:,:,2)
, etc.
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
Upvotes: 2