From: Jan Simon on
Dear Adnane!

> you're right. find(test1,1) is 1. I made a mistake while rewriting my function to post it on the forum. It's actually find(test1) with test1 being a 10000x1 matrix with 0's and 1's so i still need the for loop.

It is always a good idea to post complete working code.
I cannot see a remarkable potential for optimizing the code snippet you've shown. Does your profiler tell, that this code is a bottelneck?!
I assume, some_function1 and some_function2 could offer more possibilities for improvements. Perhaps they can be vectorized and called for a matrix outside the loop.

Kind regards, Jan