user1561713
user1561713

Reputation: 85

Function handle error in matlab

I want to call function handle model_jacobian, but i get "Error using ==> horzcat CAT arguments dimensions are not consistent.". When i pick function that leaves both a and d coefs in jacobian, everything works fine.

syms a d x;  
syms_function = a*x+d;                                                    
model_jacobian = matlabFunction(jacobian(syms_function, [a d]), 'vars', {[a d], x});
J = model_jacobian([1 1], [1 2 3 4 5 6 7 8 9]');

So how to call function handle with arguments despite the fact that they are not used there?

Upvotes: 4

Views: 778

Answers (1)

macduff
macduff

Reputation: 4685

You've probably solved this, but you may want to reconsider your vars specification. The documentation says:

The value of this parameter must be either a cell array of strings or symbolic arrays, or a vector of symbolic variables

You have a cell array of symbolic variables, which does not seem correct. I would just keep it simple like:

'vars',[ a d x])

Upvotes: 1

Related Questions