How to use arrayfun for nested loops without using memory multiple times for the same read only data
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on GPU Computing in MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!