how to vectorize this for loops?
Afficher commentaires plus anciens

4 commentaires
Stephen23
le 10 Jan 2018
@ Siddhesh Karbhari: please delete the screen shot and give us proper text code. A screen shot is useless to us: we cannot edit it, we cannot run it, we cannot copy-and-paste it into the editor, we cannot do anything with it at all. Please give us real code.
Adam
le 10 Jan 2018
We could type it all out into our editor character by character, hoping we don't make a mistake and that we don't have more useful things to do with our lives :)
Siddhesh Karbhari
le 10 Jan 2018
Modifié(e) : per isakson
le 13 Jan 2018
Jan
le 10 Jan 2018
By the way:
% Simpler:
% sigma0 * sqrt(2) ^ (1/level) ^ ((i-1)*level+j)
sigma0 * sqrt(2) ^ (i - 1 + j / level)
With a proper indentation the code looks cleaner: Ctrl-A Ctrl-I
Réponses (1)
Jan
le 10 Jan 2018
1 vote
Neither the inner nor the outer loop can be vectorized. The two imshow commands are impossible to vectorize. Do you really need them? Do you want a vectorization to increase the speed? Then start with using the profiler to find the most time consuming part of the code.
3 commentaires
Siddhesh Karbhari
le 10 Jan 2018
Jan
le 10 Jan 2018
What do you want to implement on GPU exactly? imshow, subplot, fspecial are not suitable for this, but conv2 will be fine.
Siddhesh Karbhari
le 10 Jan 2018
Modifié(e) : Siddhesh Karbhari
le 10 Jan 2018
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!