Is there an easy way to check if a vector valued symbolic function is linear? If so, is there an easy way to represent this expression in the form A*x
, where A
is a symbolic matrix and x
is the argument (i.e. is there a way to "extract" A
given x
and A*x
)?
syms x1 x2 a b c;
fx1 = [a*(x1+x2); b*x1+c*x1];
fx2 = [a*x1/log(x2); x2^2];
A=checklinearity(fx1, [x1 x2]') % should return [a, a; b+c, 0]
A=checklinearity(fx2, [x1 x2]') % should return false
Answer: There is an easy way to solve the problem using a built-in MATLAB function equationsToMatrix.