Azzera filtri
Azzera filtri

how to integral by series

2 visualizzazioni (ultimi 30 giorni)
JICHAO ZHANG
JICHAO ZHANG il 20 Giu 2023
Commentato: JICHAO ZHANG il 21 Giu 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

Risposte (1)

Dyuman Joshi
Dyuman Joshi il 20 Giu 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 Commenti
Torsten
Torsten il 20 Giu 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 il 21 Giu 2023
I see, great. using vector for t

Accedi per commentare.

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by