What if you do it like this?
syms a b
yourMat = [a*a b+a;
b^2 a^2+b^2;
a b];
newMat{1} = diff(yourMat, a);
newMat{2} = diff(yourMat, b);
Output:
>> newMat{1}
ans =
[ 2*a, 1]
[ 0, 2*a]
[ 1, 0]
>> newMat{2}
ans =
[ 0, 1]
[ 2*b, 2*b]
[ 0, 1]