If you permute gamma to be a vector along the dimension 3, then you can multiply it by identy, and the result will be a 33x33x32 array, where each "slice" along dimension 3 is the multiple with the corresponding value of gamma.
So, this calculation will do all of the calculations of your for loop (and store them all, rather than overwriting as your code does).
A = a*D2 + b*D + permute(gamma,[3,2,1]) .* identy;
You may now have a memory problem, though, if your arrays are large.