I want to integrate a symbolic matrix numerically. How can I do it??
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aninda pal
el 27 de Abr. de 2023
Comentada: Paul
el 29 de Abr. de 2023
clear all
clc
syms x y
A= [1 x^2+y^2;x-y x^2+y^2];
I want to numerically integrate all elements of A for x limits (0-10) and ylimits (0-15) .
Thanks for your time and help..
0 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Abr. de 2023
Use nested vpaintegral() calls. The inner call will execute first and figure out that it cannot integrate because there is an additional free variable, so it will return a vpaintegral() data form. The outer vpaintegral will recognize the vpaintegral data form from the inner and will be able to proceed with the 2d integration.
2 comentarios
Walter Roberson
el 28 de Abr. de 2023
syms x y
A= [1 x^2+y^2;x-y x^2+y^2];
result = vpaintegral(vpaintegral(A, x, 0, 10), y, 0, 15)
Más respuestas (2)
Paul
el 28 de Abr. de 2023
I don't think there's a function for numerically integrating an arrayvalued function of two variables. Here's a loop approach to integrating each element of A individually using integral2
syms x y
A = [1 x^2+y^2;x-y x^2+y^2];
for ii = 1:2,
for jj = 1:2
Afun = matlabFunction(A(ii,jj),'vars',{'x' 'y'});
% add 0*x to ensure proper dimension when integrating A(1,1)
result(ii,jj) = integral2(@(x,y) Afun(x,y)+0*x,0,10,0,15);
end
end
format short e
result
2 comentarios
Paul
el 29 de Abr. de 2023
syms x y
A = [1 x^2+y^2;x-y x^2+y^2];
tic
for kk = 1:100
result = nan(2,2);
for ii = 1:2,
for jj = 1:2
Afun = matlabFunction(A(ii,jj),'vars',{'x' 'y'});
% add 0*x to ensure proper dimension when integrating A(1,1)
result(ii,jj) = integral2(@(x,y) Afun(x,y)+0*x,0,10,0,15);
end
end
end
toc
tic
for kk = 1:100
result = vpaintegral(vpaintegral(A, x, 0, 10), y, 0, 15);
end
toc
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!