I am trying to do following in MATLAB,
global a b c d e f g h l;
A=[1 3;3 2];
B=[a 0;0 b];
C=[d 0;e f];
Ctranspose=transpose(C);
D=[sqrt(d) 0;0 sqrt(f)];
E=C
You didn't specify what the values of a b c d e f g h l are, you specify that they are global variables.
a) First error: Given that you get an error in line 6, it is either that a or b isn't a scalar.
b) Second error: (error is in line 4 rather than line 5). Here again one of d, e or f is not a scalar. What happens here is that d and e might be scalars, but f isn't, f is instead a vector or a matrix. So the first row of the matrix has a different length than the second row, hence the error.
What is the intend of the for loops? M==K will return true only if all elements of M and K are equal, but the element in the second row and first column will never be the same. And if somehow M and K were the same matrix, then the code would just print d, e and f for all the combinations of values of a and b. (Note that a and b are redefined in the for loop.)