While Matlab has symbolic facilities, they aren't great. Instead, you really want to vectorize your operation. This can be done in a loop, or you can use ARRAYFUN
for the job. It sounds like ARRAYFUN
would probably be easier for your problem.
The ARRAYFUN
approach:
x = 1:5;
detFunc = @(x) det([ x x^2 ; x^2 x ]);
xDet = arrayfun(detFunc, x)
Which produces:
>> xDet = arrayfun(detFunc, x)
xDet =
0 -12 -72 -240 -600
For a more complex determinant, like your 4x4 case, I would create a separate M-file for the actual function (instead of an anonymous function as I did above), and pass it to ARRAYFUN
using a function handle:
xDet = arrayfun(@mFileFunc, x);