MATLAB: How to apply numerical integration on a symbolic matrix

integration

Can I use integral2 to calculate the matrix below on the domain[0,1]*[0,1];
My matrix is much more complicated than this one, and I do not want to calculate the symbolic expression one by one~

Best Answer

Please try this is code:
fun = {@(x,y)x+y,@(x,y)x.^2+y.^2;@(x,y)x-y,@(x,y)x.^2-y.^2}
q = cellfun(@(z)integral2(z,0,1,0,1),fun);
or let fs - a your symbolic matrix, then
fun = zeros(size(fs));
for jj = 1:numel(fs)
fun = matlab2Function(fs(jj));
out(jj) = integral2(fun, 0, 1, 0, 1);
end