Effacer les filtres
Effacer les filtres

how to integral by series

2 vues (au cours des 30 derniers jours)
JICHAO ZHANG
JICHAO ZHANG le 20 Juin 2023
Commenté : JICHAO ZHANG le 21 Juin 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

Réponses (1)

Dyuman Joshi
Dyuman Joshi le 20 Juin 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 commentaires
Torsten
Torsten le 20 Juin 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 le 21 Juin 2023
I see, great. using vector for t

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by