</function diffuzia
x0=0;
xt=10000;
t0=0;
tt=120000;
m=300;
n=10000;
dt=(tt-t0)/n;
h=(xt-x0)/m;
u(1:m/2,1)=0.3;
u((m/2+1):m+1,1)=0;
for j=1:n
for i=2:m
if i==2
u(i-1,j)=u(i,j);
end
if i==m
u(i+1,j)=u(i,j);
end
u(i,j+1)=pdk(u(i,j))*dt*(u(i+1,j)-u(i,j))*(u(i,j)-u(i-1,j))/(h^2)+dk(u(i,j))*dt*(u(i+1,j)+u(i-1,j)-2*u(i,j))/(h^2)+u(i,j);
end
end
u(1,n+1)=u(2,n+1);
u(m+1,n+1)=u(m,n+1);
[xx,yy]= meshgrid(0:dt:tt,0:h:xt);
mesh(xx,yy,u);
end
></spoiler>