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!