Best way of course is to avoid loops. But you must have this in mind: Matlab is a matrix oriented tool. So the more you use matrixes the more you speed up the computations. Try to convert a loop using matixes ie by calling a matrix instead getting in a lopp. The other thing for speeding up computation is to define the dimentions of the matrix. Don't let Matlab compute the dimension. Define a matrix ie M(3,4) whenever you want to use it. I think these will help. Of course you can allways use C++ : Matlab is build it on C++ packages. So, if you can't avoid loops, then it is better to use C++. In my case, a programm in Matlab wanted ~2h to run and gave me the 1/5 of the results than the same programm in C++ with the speed of ..5min!!! It is up to you my boy!
D.