How to use arrayfun for nested loops without using memory multiple times for the same read only data
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Greetings, I wish to use arrayfun for a function (call it FOO) that takes two different inputs in1 and in2. in1 comes from IN1 which is an m1 element vector and in2 comes from IN2 (m2 elements). I wish to compute FOO(IN1(ii),IN2(jj)) for all possible ii and jj pairs. One way would be:
[OUT1]=arrayfun(@FOO,repmat(IN1,m2,1),reshape(repmat(IN2',m1,1),m1*m2,1))
But this wastes the memory so needlessly. (we pass IN1 m2 times and IN2 m1 times and we can do not even edit them so they should be in the memory only once and should not waste more)
Do anyone of you have a good idea?
Best,
Volkan
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su GPU Computing in MATLAB in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!