Triple intergral for the array valued function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I would like to perform triple intergral for my array valued function. The example of kind is below :
Generally, the command quadv works for the single variable integral. However, the integral3 or triplequad could not handle this. It throws the error. Example code below which throwing an Error. From my understanding, the integral3 can not handle array valued function. What would be the alternative way to handle this kind of situation
N1 =@(x,y,z) x.^2+y.^2+z.^2;
N2 =@(x,y,z) x.^2+y.^2+z.^2;
N3 =@(x,y,z) x.^2+y.^2+z.^2;
N4 =@(x,y,z) x.^2+y.^2+z.^2;
A =@(x,y,z)[N1(x,y,z), N2(x,y,z); N3(x,y,z), N4(x,y,z)];
integral3(A,0,2,0,2,0,2)
0 commentaires
Réponses (2)
Ayush Anand
le 12 Avr 2024
Hi,
You need to integrate each component of your array-valued function separately and then combine the results. You can call "integral3" multiple times to do this, once for each element in your array:
% Define N1,N2,N3,N4
N1 =@(x,y,z) x.^2+y.^2+z.^2;
N2 =@(x,y,z) x.^2+y.^2+z.^2;
N3 =@(x,y,z) x.^2+y.^2+z.^2;
N4 =@(x,y,z) x.^2+y.^2+z.^2;
% Integrate each component separately
I1 = integral3(N1, 0, 2, 0, 2, 0, 2);
I2 = integral3(N2, 0, 2, 0, 2, 0, 2);
I3 = integral3(N3, 0, 2, 0, 2, 0, 2);
I4 = integral3(N4, 0, 2, 0, 2, 0, 2);
% Combine the results into an array
A = [I1, I2; I3, I4];
Hope this helps!
Torsten
le 12 Avr 2024
Modifié(e) : Torsten
le 12 Avr 2024
N = cell(2,3);
N{1,1} =@(x,y,z) x.^2+y.^2+z.^2;
N{1,2} =@(x,y,z) x.^2+y.^2+z.^2;
N{1,3} =@(x,y,z) x.^2;
N{2,1} =@(x,y,z) y.^2+z.^2;
N{2,2} =@(x,y,z) x.^2+y.^2+z.^2;
N{2,3} =@(x,y,z) z.^2;
[I,J] = meshgrid(1:2,1:3);
A = arrayfun(@(i,j)integral3(N{i,j},0,2,0,2,0,2),I,J).'
2 commentaires
Torsten
le 16 Avr 2024
Modifié(e) : Torsten
le 16 Avr 2024
Does that also work with array valued function in form of matrices not cell array ?
No. Your A from above is not a matrix of 4 function handles, but 1 matrix-valued function handle. Thus the elements of the matrix are not function handles on their own and cannot be extracted as such for the 3d-integration. And integrating all matrix functions in one go is not possible with integral3.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!