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

1 view (last 30 days)
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.

Accepted Answer

Thorsten
Thorsten on 19 Nov 2015
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.

More Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!