From: Theguyfromstarwars on
Hi,
I'm trying to differentiate an expression that involves a function I wrote myself (vectrot(p, r, theta) below, which returns a vector).

I want to differentiate it wrt theta, so I can minimise the angle theta. I'm giving it the following:

>> xax = [1;0;0];
>> abc = [-0.57932250769383;-0.030187965400549;0.814539206437792;];
>> syms theta
>> f = (vectrot(xax, abc, theta) - [1;1;1])^2

At this point I keep getting the error:
??? The following error occurred converting from sym to double:
Error using ==> sym.double
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.

Can anyone explain what I'm doing wrong here? Is there a better way of going about this?

Thanks.