Borrar filtros
Borrar filtros

calculate integration of function

1 visualización (últimos 30 días)
MADHVI
MADHVI el 13 de Ag. de 2023
Comentada: Star Strider el 14 de Ag. de 2023
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 comentario
Dyuman Joshi
Dyuman Joshi el 13 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 13 de Ag. de 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.')
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 comentarios
MADHVI
MADHVI el 14 de Ag. de 2023
Thanks.
Star Strider
Star Strider el 14 de Ag. de 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by