calculate integration of function

1 次查看(过去 30 天)
MADHVI
MADHVI 2023-8-13
clc
clear
syms x y z D L B A(m, n, j, t) R
nfin = 1; nffin = 3; % length of summation of n
jfin = 1; jffin = 3; % length of summation of j
mfin = 1; mffin = 3; % length of summation of m
rowmat = [0];
for kk1=nfin:nffin
for kk2 = jfin:jffin
for kk3 = mfin:mffin
rownew = A(kk1, kk2, kk3, t)*sin(kk1*pi*x)*cos(kk2*pi*D*y/L)*cos(kk3*D*pi*z/B);
rowmat = [rowmat rownew];
end
end
end
Phiterms = rowmat(2:end);
Phi = sum(Phiterms.')
size(Phiterms)
diff(Phi,y,2)+diff(Phi,z,2)),t,1)+diff(diff(Phi,y,1),x,1)*(diff(diff(Phi,y,1),x,2)+diff(diff(Phi,y,1),y,2)+diff(diff(Phi,y,1),z,2))+diff(diff(Phi,z,1),x,1)*(diff(diff(Phi,z,1),x,2)+diff(diff(Phi,z,1),y,2)+diff(diff(Phi,z,1),z,2))-(diff(Phi,y,2)+diff(Phi,z,2))*(R+(diff(diff(Phi,x,1),x,2)+diff(diff(Phi,x,1),y,2)+diff(diff(Phi,x,1),z,2)))==diff(Phi,x,4)+diff(Phi,y,4)+diff(Phi,z,4)
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
colmat=[];
for kk1=nfin:nffin
for kk2=mfin:mffin
for kk3=jfin:jffin
colnew1 = int(ans*sin(kk1*pi*x), 0, 1);
colnew2 = int(colnew1*cos(kk2*pi*y*D/L), 0, L/D);
colnew3 = int(colnew2*cos(kk3*pi*z*D/B), 0, B/D);
colmat = [colmat; colnew3];
end
end
end
Phi_terms = colmat(2:end);
Phi_ = sum(Phi_terms);
size(Phi_terms)
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-8-13
You have undefined variables in your code - m, n, j, and t.
Also, please explain what you are doing here, what is the objective and what error/problem you are facing.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2023-8-13
This term, near the beginning of what I call ‘EXPR’
diff(Phi,y,2)+diff(Phi,z,2),t,1)+ ...
needs an extra diff call:
diff(Phi,y,2)+diff(diff(Phi,z,2),t,1)+ ...
then it works.
Beyond that, it’s not obvious what this code does, however with that change (even though you do not appear to do anything with that value) the code runs without error —
syms x y z D L B A(m, n, j, t) R
nfin = 1; nffin = 3; % length of summation of n
jfin = 1; jffin = 3; % length of summation of j
mfin = 1; mffin = 3; % length of summation of m
rowmat = [0];
for kk1=nfin:nffin
for kk2 = jfin:jffin
for kk3 = mfin:mffin
rownew = A(kk1, kk2, kk3, t)*sin(kk1*pi*x)*cos(kk2*pi*D*y/L)*cos(kk3*D*pi*z/B);
rowmat = [rowmat rownew];
end
end
end
Phiterms = rowmat(2:end);
Phi = sum(Phiterms.')
Phi = 
size(Phiterms)
ans = 1×2
1 27
EXPR = diff(Phi,y,2)+diff(diff(Phi,z,2),t,1)+diff(diff(Phi,y,1),x,1)*(diff(diff(Phi,y,1),x,2)+diff(diff(Phi,y,1),y,2)+diff(diff(Phi,y,1),z,2))+diff(diff(Phi,z,1),x,1)*(diff(diff(Phi,z,1),x,2)+diff(diff(Phi,z,1),y,2)+diff(diff(Phi,z,1),z,2))-(diff(Phi,y,2)+diff(Phi,z,2))*(R+(diff(diff(Phi,x,1),x,2)+diff(diff(Phi,x,1),y,2)+diff(diff(Phi,x,1),z,2)))==diff(Phi,x,4)+diff(Phi,y,4)+diff(Phi,z,4)
EXPR = 
colmat=[];
for kk1=nfin:nffin
for kk2=mfin:mffin
for kk3=jfin:jffin
colnew1 = int(ans*sin(kk1*pi*x), 0, 1);
colnew2 = int(colnew1*cos(kk2*pi*y*D/L), 0, L/D);
colnew3 = int(colnew2*cos(kk3*pi*z*D/B), 0, B/D);
colmat = [colmat; colnew3];
end
end
end
Phi_terms = colmat(2:end);
Phi_ = sum(Phi_terms);
size(Phi_terms)
ans = 1×2
1 53
.
  2 个评论
Star Strider
Star Strider 2023-8-14
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by