calculate integration of function
조회 수: 3 (최근 30일)
이전 댓글 표시
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)
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
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
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.')
size(Phiterms)
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)
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)
.
댓글 수: 2
Star Strider
2023년 8월 14일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!