How to implement a multiple nested “nested loop” faster in MATLAB
I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this?I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this? I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this? speed, for loop, nested-for loop MATLAB Answers — New Questions