First, read up on Maple's Vector and Matrix and Array types as you will need these.

The matrix Q is not initialized and you are using an undefined element (Q(3,3)), so you need to initialize it in some fashion. The simple way is to use the bracket notation:

Q:=<<1,2,3>|<4,5,6>|<7,8,9>>;

where each triplet becomes one column.

The assignments to T should work once you replace the = with := . In Maple, = is a logical operator (unless used to assign to keyword parameters in function calls), assignments are done with := . The reason this works because of something called "Programmer Indexing"; read up on it in the Programming Guide (a very worthwhile document if you want to learn Maple in earnest). However, the "proper way" to do this woud be to declare T and use [ ] for the indexing:

T:=Matrix(3,3,datatype=float);

...

for i from 1 to numelems(R) do

T[1,1]:=cos(R[i])^2;

...

end do;

which reminds me that R is not assigned anything either. Since you are showing a code snippet, these assignments are presumably happening earlier.

inv() is presumably Matlab's matrix inverse, in Maple this is LinearAlgebra:-MatrixInverse().

Matrix multiplication in Maple is . (period). * will either fail or do element-wise multiplication. Strictly speaking, element-wise operators have a trailing tilde, e.g. A*~B, but in newer Maple versions the tilde's are not always necessary.

That leaves the Qk(:;:;i) construct, that I don't know off hand how to handle, esp. not knowing Matlab very well. Presumably, Qk is a 3 by 3 by numelems(R) Matrix. In Maple, that would be an Array (Maple's Matrices are 2-d; Arrays can have any number of dimensions). Matlab's wild card index : is .. (two dots) in Maple; but I have had a lot of trouble with constructs like Qk[..,..,i]. You'll need to experiment here. Another potential pitfall is that Qk[..,..,i] for a given i is NOT of type Matrix. To use the LinearAlgebra routines on it you'd need to convert it with

convert(Qk[..,..,i],Matrix);

In Maple, you could also do this as a list of Matrices; i.e.

Qk:=[M1,M2,M3,M4];

and your Qk(:;:;i) would become something like Qk[i][..,..] . Again, you will want to try these until it works the wayyou want it to.

Finally, be aware that Maple can (and often will) merrily store whole expressions of ever-increasing length if it runs across undefined variables ("names" in Maple lingo). Specifying the datatype as float in the various declarations helps identifying such situations as Maple will barf if you try to assign an unevaluated expression to a float.

I hope this helps some what.

Mac Dude