필터 지우기
필터 지우기

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