I have an array of N
position vectors which form an N-by-3 matrix. I want to transform these position vectors to another coordinate system. The 3-by-3 rotational transformation matrix is same for all position vectors. How can I use arrayfun
or bsxfun
for this purpose for minimising computation time?
1
votes
arrayfun
is very unlikely to minimise computation time over a simplefor
-loop. It's just wrapping a loop up with a bit of extra overhead.bsxfun
does produce a speedup often, however matrix multiplication withbsxfun
is not simple. Luckily for you, you need neither as*
will suffice. – DanNx3
? BothN
and3
should be code, I believe (but the former definitely). And you don't need superfluous edits for a title change. – Andras DeakN
and N are completely different in this case and the ambiguity caused by writingNx3
is precisely why I prefer to use MATLAB's documentation's formatting.Nx3
could be a variable name,N*3
is even worse as it could be the matixN
(which actually exists in this case!) multiplied by the scalar3
. Since N and 3 in this case are never actually typed in code but rather almost meta data to the data structures in the code, I prefer to not use code tags for them. If it wasn
-by-3 I would though ifn
was a variable. – DanN
position vectors which I misread as an arrayN
of position vectors. Mostly because I expect something in code tags to be a variable, but in this instance I see my error and the twoN
s are indeed the same. Personally I think that neither should be in code tags though. – Dan