Need help plotting T(x,y,z,t) at different times?!

Sorry, I think I accepted an answer so my thread closed. I'm new here.
I want to plot the first few terms of this triple sum I solved for (should be a good approximation) I was thinking about showing the initial temperature distribution (t=0), and then T(x,y,z,t=100000) or something to show how it disipated over time. Im not sure how to go about it. Here is the sum I have.
Ill also post the code I came up with, essentially I have a function, with 4 variables, T(x,y,z,t). I hope this is clear. Here is what I've tried. Id appreciate any help. I just want to plot that function at different values of t :(
clc; clear all; close all
k=46; %conductivity
rho=3970; %material density
cp=765; %specific heat
alpha=k/(rho*cp);
x=0:pi;
y=0:pi;
z=0:pi;
t=0:10;
T=@(x,y,z,t) (1.376*sin(x).*sin(y).*cos(0.5*z).*exp((-2.25*alpha*t))+(0.153*sin(3*x).*sin(3*y).*cos(0.5*z).*exp((-18.25*alpha*t)-(0.055*sin(5*x).*sin(5*y).*cos(0.5*z).*exp((-50.25*alpha*t))-(0.827*sin(x).*sin(y).*co(1.5*z).*exp((-4.25*alpha*t)-(0.092*sin(3*x).*sin(3*y).*cos(1.5*z).*exp((-20.25*alpha*t)-(0.33*sin(5*x).*sin(5*y).*cos(1.5*z).*exp((-52.25*alpha*t));
x=0:pi;
y=0:pi;
z=0:pi;
t=0:10;
surf(T)

답변 (2개)

Walter Roberson
Walter Roberson 2012년 10월 12일

0 개 추천

[X, Y, Z] = ndgrid(x, y, z);
T0 = T(X, Y, Z, 0);
subplot(2,1,1);
surf(T0);
subplot(2,1,2);
T10000 = T(X, Y, Z, 10000);
surf(T10000);
But I suggest you double-check what the result is of
x=0:pi;
Jonathan
Jonathan 2012년 10월 12일

0 개 추천

Hey, thanks for your response! I'm getting an error that I cant seem to reconcile.
Undefined function 'co' for input arguments of type 'double'.
Error in @(x,y,z,t)(1.376.*sin(x).*sin(y).*cos(0.5*z).*exp((-2.25*alpha*t))+(0.153*sin(3*x).*sin(3*y).*cos(0.5*z).*exp((-18.25*alpha*t)-(0.055*sin(5*x).*sin(5*y).*cos(0.5*z).*exp((-50.25*alpha*t))-(0.827*sin(x).*sin(y).*co(1.5*z).*exp((-4.25*alpha*t)-(0.092*sin(3*x).*sin(3*y).*cos(1.5*z).*exp((-20.25*alpha*t)-(0.33*sin(5*x).*sin(5*y).*cos(1.5*z).*exp((-52.25*alpha*t)))))))))))
Error in Untitled (line 19) T0 = T(X, Y, Z, 0);

댓글 수: 3

Matt Kindig
Matt Kindig 2012년 10월 12일
편집: Matt Kindig 2012년 10월 12일
The error is because there is no function 'co' on your path. The error appears to be in the "co(1.5*z)" expression-- should it be "cos(1.5*z)"?
Jonathan
Jonathan 2012년 10월 12일
Haha thanks :). I'm still getting an error. Here is my code:
clc; clear all; close all
k=46; %conductivity rho=3970; %material density cp=765; %specific heat
alpha=k/(rho*cp);
T=@(x,y,z,t) (1.376.*sin(x).*sin(y).*cos(0.5*z).*exp((-2.25*alpha*t))+(0.153*sin(3*x).*sin(3*y).*cos(0.5*z).*exp((-18.25*alpha*t)-(0.055*sin(5*x).*sin(5*y).*cos(0.5*z).*exp((-50.25*alpha*t))-(0.827*sin(x).*sin(y).*cos(1.5*z).*exp((-4.25*alpha*t)-(0.092*sin(3*x).*sin(3*y).*cos(1.5*z).*exp((-20.25*alpha*t)-(0.33*sin(5*x).*sin(5*y).*cos(1.5*z).*exp((-52.25*alpha*t)))))))))));
x=0:pi; y=0:pi; z=0:pi; t=0:10;
[X, Y, Z] = ndgrid(x, y, z);
T0 = T(X, Y, Z, 0); subplot(2,1,1); surf(T0);
subplot(2,1,2); T10000 = T(X, Y, Z, 10000); surf(T10000);
Here is my error:
CData must be an M-by-N matrix or M-by-N-by-3 array
Error in graph3d.surfaceplot>localConstructor (line 136) h = graph3d.surfaceplot(argin{:});
Error in graph3d.surfaceplot (line 7) h = localConstructor(varargin{:});
Error in surf (line 98) hh = double(graph3d.surfaceplot(args{:},'parent',parax));
Error in Untitled2 (line 15) surf(T0);
Is CData color stuff? Thanks guys, I appreciate it :)
Ah, the problem is that I suggested that you surf() a 3D matrix of information, which is not possible.
How were you hoping to represent the 4D plot T(x range, y range, z range, fixed temperature) in a 2.5D graphics system ?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

질문:

2012년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by