%%Parameters
Q = 137653.6; %J/mol
R = 8.314; %J/mol/K
T0 = 473.15; %K
r = 10; %Cooling history in kelvins per myr
c = 7.5e-5; %m
D0 = c^2.*exp(13.4); %m^2/s
A0 = 0; %Initial age
T = T0 - r.*t;D = D0.*exp(-Q/R.*T);tmax = 50e6* 365*24*3600; % in seconds !!
%%Discretisation
Dx = 1e-5;%
Dtmax = 0.5*Dx^2./D;%Dt = 0.5.*Dtmax;%%time vector:
t = 0:Dt:tmax;%space vector:
x = 0:Dx:c;%number of nodes in time and space:
N = length(t);I = length(x);%%initialisation
T = zeros(N,I);%initial conditions:
T(1,:) = 0;%%iterations
for n=1:N-1%boundary conditions:
T(n+1, 1) = 0;T(n+1, I) = 0;%interior points:
for in=2:I-1T(n+1, in) = T(n, in) + (alpha*Dt/Dx^2)*(T(n,in+1) ...- 2*T(n,in) + T(n, in-1));endend%%plots
figure;[c, h] = contour(t/(1e6*24*3600*365), T', 'K');clabel(c, h);xlabel('time (My)')ylabel('depth (km)')
MATLAB: Hi, I keep getting the same error of Z must be a 2×2 matrix with the following code. Any takers willing to help a desperate student
contour issue
Best Answer