我想创建一个地球覆盖的草的最后部分的3D图(从现在开始的20亿年)(= A)作为草的死亡率(= D)和草的生长速率的函数(= G).
A的最终值(距离现在20亿年)可以使用具有以下discritised方程的循环来计算:
A(t + dt)= A(t)*((1-A(t))*GD)*dt + A(t)
%Define variables and arrays
D=0.1; %constant value
G=0.4; %constant value
A=0.001; %initial value of A at t=0
t=0;
dt=10E6;
startloop=1; %define number of iterations
endloop=200;
timevector=zeros(1,endloop); %create vector with 0
grassvector=zeros(1,endloop);
%Define the loop
for t=startloop:endloop
A=A.*((((1-A).*G)-D)) + A;
grassvector(t)=A;
timevector(t)=t*dt;
end
Run Code Online (Sandbox Code Playgroud)
现在我停留在如何创建A的最终值的3D图表作为变化的G和D的函数.我得到了这个,但经过几次试验后,它一直给出错误:
%(1) Create array of values for G and D varying between 0 and 1
A=0.001;
G=[0.005:0.005:1]; %Vary from 0.005 to 1 in steps of 0.005
D=[0.005:0.005:1]; …Run Code Online (Sandbox Code Playgroud) 如果你有一个随机矩阵,例如5x5:
A(i,j) = (5 4 3 2 1
4 3 2 1 0
5 4 3 2 1
4 3 2 1 0
5 4 3 2 1)
Run Code Online (Sandbox Code Playgroud)
第二个阵列:
B(1,j) = (4 5 6 7 8)
Run Code Online (Sandbox Code Playgroud)
如果只有当B(1,j)的值大于A的某个colomn值时,才需要将B的值赋值给A?
例如,B(1,1)= 4并且在A的第一个colomn中它大于A(1,1),A(3,1)和A(5,1),所以这些必须被4替换在第二个colomn中,没有什么需要更换,等等.
谢谢!