matlabFunction happily handles matrices of parameters, with the meaning that the resulting function is called with a matrix in that place, but for reasons of MATLAB syntax, that requires you hand it a cell array. In the following, I've abbreviated the outputs for readability:
>> A = sym('A',[4,4]);
>> B = sym('B',[4,3]);
>> A*B
ans =
[ A1_1*B1_1 + A1_2*B2_1 + A1_3*B3_1 + A1_4*B4_1, ...
[ A2_1*B1_1 + A2_2*B2_1 + A2_3*B3_1 + A2_4*B4_1, ...
[ A3_1*B1_1 + A3_2*B2_1 + A3_3*B3_1 + A3_4*B4_1, ...
[ A4_1*B1_1 + A4_2*B2_1 + A4_3*B3_1 + A4_4*B4_1, ...
>> matmult = matlabFunction(A*B, 'Vars', {A, B})
matmult =
@(in1,in2)reshape([in1(1).*in2(1)+in1(5).*in2(2)+in1(9).*in2(3)+...
>> matmult(magic(4), reshape(1:12,[4,3]))
ans =
81 217 353
89 225 361
89 225 361
81 217 353
There is currently no way to say that A is supposed to denote an abstract matrix.
