Question: CodeGeneration & diff problem

Hi,

I have a frustrating error that comes from using Code generation with diff

It works fine when processing a single equation but doesn't like matricies:

> Xx := ((cos(q1)*cos(q2)+0.8e-3*sin(q1)*sin(q2))*sin(q3)+(0.8e-3*(-cos(q1)*sin(q2)+0.8e-3*sin(q1)*cos(q2)))*cos(q3)+sin(q1)*cos(q3))*L3+(0.8e-3*(cos(q1)*sin(q2)-0.8e-3*sin(q1)*cos(q2)+0.8e-3*sin(q1)))*L3+sin(q1)*(L21+L22);

> Matlab(diff(Xy, q1));
cg86 = ((-0.8e-3 * cos(q1) * cos(q2) - 0.64e-6 * sin(q1) * sin(q2)) * sin(q3) + 0.8e-3 * (0.8e-3 * cos(q1) * sin(q2) - 0.64e-6 * sin(q1) * cos(q2)) * cos(q3) - 0.8e-3 * sin(q1) * cos(q3)) * L3 + 0.8e-3 * (-0.8e-3 * cos(q1) * sin(q2) + 0.64e-6 * sin(q1) * cos(q2) - 0.64e-6 * sin(q1)) * L3 - 0.8e-3 * sin(q1) * (L21 + L22);
>
> J := Vector[row](3, {(1) = diff(Xx, q1), (2) = diff(Xx, q2), (3) = diff(Xx, q3)});
(This produces a working output but copy and paste from Maple doesn't seem to work here...)
> Matlab(J);
Warning, the function names {diff} are not recognized in the target language
cg84 = [diff(Xx, q1) diff(Xx, q2) diff(Xx, q3)];


And that's it! Any ideas anyone? The above is just a sample problem btw, my actual matricies (Jacobians fyi) are larger and it is quite tedious to copy element by element to Matlab (especially during debugging loops).

Please Wait...