I do not understand the error I am obtaining. When I do not use the values of x,y,and z i get an answer, but when i use them i get an error.

1 次查看(过去 30 天)
I do not understand the error I am obtaining. When I do not use the values of x,y,and z i get an answer, but when i use them i get an error.
syms x y z f g
%%%%%Variable Values%%%%%%%%%
n=0;
m=0;
k = (0.6569);
h = 11;
alpha = 2.57*10^(-7);
t=0;
L=(.051);
W=(.01);
H=(.005);
% x=(.051/4);
% y=(.01/2);
% z=(.005/4);
beta = ((n+0.5)*pi);
eta = ((m/.01)*pi);
mew = (117);
lamda = (((n+0.5)*pi))^2+(117)^2+(((m/.01)*pi))^2;
%%%%%%%%DETERMINATION OF CONSTANT C%%%%%%%%%%%%%%%%
f(z,y,x) = cos(beta*z)*sin(mew*y)*cos(eta*x)*sin(eta*x);
C_nmp_numerator = int(int(int(f,z,[0 (H/2)]),y,[0 W]),x,[0 (L/2)]);
g(z,y,x) = (cos(beta*z))^2*(sin(mew*y))^2*((((-k*mew)/h)*(cos(mew*x))^2*sin(mew*x))+((sin(mew*x))^2*cos(mew*x)));
C_nmp_denominator = int(int(int(g,z,[0 (H/2)]),y,[0 W]),x,[0 (L/2)]);
C_nmp = C_nmp_numerator/C_nmp_denominator;
%%%%%%%%DETERMINATION DEMENTIONLESS TEMP THETA%%%%%%%%%%%%%%%%
theta = (C_nmp * cos(beta*z)*sin(eta*y)*((-k*mew)/h)*cos(mew*x)+sin(mew*x))*exp(-(lamda*lamda)*alpha*t)

采纳的回答

Walter Roberson
Walter Roberson 2021-12-5
syms x y z f g
x y z are symbolic
% x=(.051/4);
% y=(.01/2);
% z=(.005/4);
If those had the comment marks removed, the resulting x y z would be numeric and not integers
f(z,y,x) = cos(beta*z)*sin(mew*y)*cos(eta*x)*sin(eta*x);
When x, y, z are symbolic, that statement defines a symbolic function that relates symbolic names x, y, z to a formula.
When x, y, z are numeric, that statement calculates a specific numeric value on the right hand side, and tries to assign to to array f indexed at locations 0.00125, 0.005, 0.01275 . But those are not positive integers, so the indexing fails.
C_nmp_numerator = int(int(int(f,z,[0 (H/2)]),y,[0 W]),x,[0 (L/2)]);
If you had managed to fix the above f(z,y,x) definition so that f became a numeric scalar, then you would not be able to int() a numeric scalar.
  1 个评论
Walter Roberson
Walter Roberson 2021-12-5
So what can you do? This:
syms x y z f g
%%%%%Variable Values%%%%%%%%%
n=0;
m=0;
k = (0.6569);
h = 11;
alpha = 2.57*10^(-7);
t=0;
L=(.051);
W=(.01);
H=(.005);
X=(.051/4);
Y=(.01/2);
Z=(.005/4);
beta = ((n+0.5)*pi);
eta = ((m/.01)*pi);
mew = (117);
lamda = (((n+0.5)*pi))^2+(117)^2+(((m/.01)*pi))^2;
%%%%%%%%DETERMINATION OF CONSTANT C%%%%%%%%%%%%%%%%
f(z,y,x) = cos(beta*z)*sin(mew*y)*cos(eta*x)*sin(eta*x);
C_nmp_numerator = int(int(int(f,z,[0 (H/2)]),y,[0 W]),x,[0 (L/2)]);
g(z,y,x) = (cos(beta*z))^2*(sin(mew*y))^2*((((-k*mew)/h)*(cos(mew*x))^2*sin(mew*x))+((sin(mew*x))^2*cos(mew*x)));
C_nmp_denominator = int(int(int(g,z,[0 (H/2)]),y,[0 W]),x,[0 (L/2)]);
C_nmp = C_nmp_numerator/C_nmp_denominator;
%%%%%%%%DETERMINATION DEMENTIONLESS TEMP THETA%%%%%%%%%%%%%%%%
theta = (C_nmp * cos(beta*z)*sin(eta*y)*((-k*mew)/h)*cos(mew*x)+sin(mew*x))*exp(-(lamda*lamda)*alpha*t)
theta = 
vpa(subs(theta, {x, y, z}, {X, Y, Z}))
ans = 
0.99687746550155485732270131796321

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by