MATLAB: How to define a multivariable function (for instance an anonymous function) of a number of variables that varies according to the size of an array variable

functionnumber of variables

My aim is to compute the point of minimum value for a function which is a determinant of the product of 3 matrices where the columns of the first and third are functions of a variable each.

Best Answer

Define your function as
function y = myfun(a,b)
A = [-a a; a -a]; % sample definition
B = rand(2);
C = [-2*b b; -4*b b]
y=det(A*B*C)
Use fminsearch to find the minimum of that function.