The simplest way I can think of is to combine arrayfun and cell2mat functions:
B = cell2mat(arrayfun((@(x) T .* x), A, 'UniformOutput', false)); First, we transform ourI transformed matrix A into a cell array of matrices T .* x, where x is an element of A (a assumed here that T is a matrix).
Then we useI used cell2mat to transform in back into a matrix.
Here is a complete example (execute online):
A = magic(3); T = diag([-1 1]); B = cell2mat(arrayfun((@(x) T .* x), A, 'UniformOutput', false)); resulting in:
B = -8 0 -1 0 -6 0 0 8 0 1 0 6 -3 0 -5 0 -7 0 0 3 0 5 0 7 -4 0 -9 0 -2 0 0 4 0 9 0 2