How to use arrayfun for nested loops without using memory multiple times for the same read only data
古いコメントを表示
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 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!