Clear Filters
Clear Filters

How to integrate a matrix using dblquad to find Energy error

1 view (last 30 days)
I needed a little advise on how to find the ‘Energy-Error'.
For example, let the finite elements be square ,
let A = [-1 -5 1; 3 2 0; 2 -1 1], the finite element solution matrix ( 3x3).
Let A11= [ -1 5 ; 3 2], A12=[-5 1 ;2 0], A21=[3 2, 2 -1] A22= [2 0, -1 1]
be the 2x2 matrices of the finite element solution matrix(A).
D = [0,1] x [0,1], be the square domain and h=0.5.
What I want to do is -integrating the square of the difference in the gradients within an element and then integrating over each element of the grid (using dblquad) and summing. I have tried the following way:
Let u(x,y) = x.*(1-exp((y-1)))/(1-exp(-2)), be the exact solution of the given equation.
Let [A11 x, A11y] = gradient(A11,0.5,0.5) be gradient of A11 (2x2 matrix).
Let the gradient of the exact solution u be
grad1 = diff(u(x,y),x)
grad2 = diff(u(x,y),y)
gradu = simplify([grad1;grad2])
Therefore, we have
z = (grad1 - A11x) ^ 2 + (grad2 - A11y) ^ 2
which is for one element.
Then I use the dblquad integration to find the integration of z i.e.,
Q = dblquad(@(x,y) z, xmin, xmax, ymin, ymax, tol)
but error occurred.
Please help me to integrate ‘z’ over each element of the grid (using dblquad) and then summing all 4 elements integration.
Thank you for everything !

Answers (0)

Categories

Find more on Matrix Computations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!