How to plot a 3D graph?

I wrote a code to measure the temperature in terms of time and depth but when I plot my 3D graph, the temperature's values increased significantly from their 2D values and I would like to know why?
Here is my code:
alpha=0.128e-6;
Ts=-20; Ti=10;
t=linspace(0,2.592*10^6,75);
z=linspace(0,3,75);
T=(erf(z./(2*sqrt(alpha.*t)))*(Ti-Ts))+Ts;
[tt,zz]=meshgrid(t,z);
TT=tt.^2-zz.^2;
surf(zz,tt,TT);
xlabel('depth')
ylabel('time')
zlabel('temperature')

Respuestas (1)

Chad Greene
Chad Greene el 6 de Oct. de 2015
Editada: Chad Greene el 6 de Oct. de 2015

0 votos

This isn't a problem with plotting, it's a problem with your data. See:
hist(TT(:))
Your TT matrix has some pretty big values in it, whereas your T matrix has values mostly in the range of -10 to 10 degrees.
Why aren't you calculating TT the same way you calculated T?
TT=(erf(zz./(2*sqrt(alpha.*tt)))*(Ti-Ts))+Ts;

3 comentarios

Thomas Chateauvert
Thomas Chateauvert el 6 de Oct. de 2015
Editada: Walter Roberson el 6 de Oct. de 2015
I changed my code and my TT but I get a pretty funky graph why?
alpha=0.128e-6;
Ts=-20; Ti=10;
t=linspace(0,2.592*10^6,75);
z=linspace(0,3,75);
[tt,zz]=meshgrid(t,z);
TT=(erf(zz./(2*sqrt(alpha.*tt)))*(Ti-Ts))+Ts;
surf(zz,tt,TT);
xlabel('depth')
ylabel('time')
zlabel('temperature')
Chad Greene
Chad Greene el 6 de Oct. de 2015
Without any context it's hard to know what you mean by funky or what the surface should look like. Matlab's plotting the data you're giving it, so I can only assume the issue is with the data. Be descriptive about what's wrong with the surface above, and what you want it to look like.
Chad Greene
Chad Greene el 6 de Oct. de 2015
Did you mix up the order of zz and tt when plotting? Try this:
pcolor(tt,zz,TT);
shading interp
xlabel('time')
ylabel('depth')
set(gca,'YDir','reverse')
cb = colorbar;
ylabel(cb,'temperature')
Note I opted for pcolor although surfaces look cool, they're rarely of great use for displaying scientific data.

Iniciar sesión para comentar.

Categorías

Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Oct. de 2015

Comentada:

el 6 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by