Hello. I have an issue with a code performing some array operations. It is getting to slow, because I am using loops. I am trying for some time to optimize this code and to re-write it with less or without loops. Until now unsuccessful. Can you please help me solve this:
YVal = 1:1:100000;M_MAX = 1000;N_MAX = 2000;clear YTempticfor M=1:1:M_MAX for N = 1:1:N_MAX YTemp(M,N) = sum(YVal (N+1:N+M) ) - sum(YVal (1:M) ); endend
For large N_MAX and M_MAX the execution time of these two loops is very high. How can I optimize this?
Thank you,
Florin
Best Answer