Borrar filtros
Borrar filtros

how to integral by series

2 visualizaciones (últimos 30 días)
JICHAO ZHANG
JICHAO ZHANG el 20 de Jun. de 2023
Comentada: JICHAO ZHANG el 21 de Jun. de 2023
I would like to do a cycle for t.
for example, function as t*exp(xyz),
then for t=1:5; there are vector
1*exp(xyz),2*exp(xyz),3*exp(xyz),4*exp(xyz),5*exp(xyz),
next step make sum, 1*exp(xyz)+2*exp(xyz)+3*exp(xyz)+4*exp(xyz)+5*exp(xyz),
finally, do integral by x,y,z varibles
f=0;
for t=1:5
f=f+@(x,y,z) t.*exp(xyz)
end
ff=integral3(@(x,y,z)f,0,1,0,1,0,1)
this is wrong code,but i don't know how to code right one

Respuestas (1)

Dyuman Joshi
Dyuman Joshi el 20 de Jun. de 2023
You can not add function handles together. Instead, you can add the integrals.
format long
f=0;
for t=1:5
%I am assuming you want to do multiplication by using the notation xyz
fun = @(x,y,z) t.*exp(x.*y.*z);
%Adding integral values
f = f + integral3(fun,0,1,0,1,0,1);
end
f
f =
17.197486087940671
  3 comentarios
Torsten
Torsten el 20 de Jun. de 2023
Or simply:
f = @(x,y,z) sum((1:5)*exp(x*y*z));
ff = integral3(@(X,Y,Z)arrayfun(@(x,y,z)f(x,y,z),X,Y,Z),0,1,0,1,0,1)
ff = 17.1975
JICHAO ZHANG
JICHAO ZHANG el 21 de Jun. de 2023
I see, great. using vector for t

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by