calculate integration of function
3 views (last 30 days)
Show older comments
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 Comment
Dyuman Joshi
on 13 Aug 2023
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.
Answers (1)
Star Strider
on 13 Aug 2023
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 Comments
Star Strider
on 14 Aug 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!