MATLAB: How can i sum the final multiplication

summation sum

Hi There, when i run this code I'm left with four values for A which are the right in values, but summing the four answers all together is what I'm actually looking for. NOTE: ReducedStiffness & Qbar are both functions defined in advance thank you for your help
clear
Q=ReducedStiffness(5.6,1.2,0.26,0.6);
Qbarr=zeros(3,3,4);Z=zeros(1,1,4);th=[0 90 90 0];z=[0:0.005:0.02];
for ii=1:4
Qbarr(:,:,ii)=Qbar(Q,th(ii));
end
for ii=1:4
Z(:,:,ii)=z(ii+1)-z(ii);
end
A=Qbarr.*Z;
A(:,:,1) =
0.0284 0.0016 0
0.0016 0.0061 0
0 0 0.0030
A(:,:,2) =
0.0061 0.0016 -0.0000
0.0016 0.0284 0.0000
-0.0000 0.0000 0.0030
A(:,:,3) =
0.0061 0.0016 -0.0000
0.0016 0.0284 0.0000
-0.0000 0.0000 0.0030
A(:,:,4) =
0.0284 0.0016 0
0.0016 0.0061 0
0 0 0.0030

Best Answer

S = sum(A,dim);
Reading the documentation can be useful.
If you want the sum of all elements, you can use
S = sum(A(:));