MATLAB: Help! Z must be a matrix, not a scalar or vector

cdata must be an m-by-n matrix or m-by-n-by-3 arrayMATLABsurf(xyz)zz is not a matrix

hello i'm trying to heat conduction 3d using matlab 2010
clc
Lx=1;
Ly=1;
Lz=1;
M=10;
N=10;
Z=10;
Q=zeros(M,N,Z);
Q(M,N,Z)=100;
%Dx=Lx/M;
%Dy=Ly/N;
%Dz=Lz/Z;
T=400*ones(M,N,Z);
T(:,:,1)=500; %boundary temperature
for i=1:100
for m=2:M-1
for n=2:N-1
for z=2:Z-1
T(m,n,z) = (100/6) * ( (T(m-1,n,z)+T(m+1,n,z)+T(m,n-1,z)+T(m,n+1,z)...
+T(m,n,z+1)+T(m,n,z-1)))+ Q(m,n,z);
end
end
end
surf(T)
colorbar
drawnow
end
and i can't solve the error 'z is not a matrix' and 'CData must be an M-by-N matrix or M-by-N-by-3 array'. what's wrong in this code? code means that set initial temperature and heat the domain plus Q.

Best Answer

You can use surf only to display a 2D surface, but not for volume data. For volume data, have a look at http://de.mathworks.com/help/matlab/visualize/overview-of-volume-visualization.html.