4D integral using integral and integral3

1 Ansicht (letzte 30 Tage)
亮介 桶谷
亮介 桶谷 am 18 Okt. 2023
Kommentiert: 亮介 桶谷 am 18 Okt. 2023
I tried 4D integral using integral and integral3 like the following link: https://jp.mathworks.com/help/matlab/ref/integral3.html
however, it does not work when a function used become complecated.
Here I show a simplified code I used.
f = @(a, b, c, d) a+b+c+d;
I = @(a, b, c) integral(@(d) f(a, b, c, d), 0, 1);
f2=@(a, b, c) I(a,b,c)+1;
I2=integral3(f2, 0, 1, 0, 1, 0, 1);
It showed an error like "The array size does not fit this operation." (translated from Japanese).
But I did not figure out which array it said.
My question is what is the acutual issue and how to solve it to achieve the 4D integral.

Akzeptierte Antwort

Matt J
Matt J am 18 Okt. 2023
f = @(a, b, c, d) a+b+c+d;
I = @(a, b, c) integral(@(d) f(a, b, c, d), 0, 1,'ArrayValued',1);
f2=@(a, b, c) I(a,b,c)+1;
I2=integral3(f2, 0, 1, 0, 1, 0, 1)
I2 = 3.0000
  1 Kommentar
亮介 桶谷
亮介 桶谷 am 18 Okt. 2023
Thank you!!
'ArrayValued' also solved problem in my actual code!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by