implicit expansion for arrayfun
4 ビュー (過去 30 日間)
古いコメントを表示
I want to do something similar to bsxfun, but for more than 2 arrays. For example
arrayfun(@f, A,B,C,D)
where A is a m-by-n matrix, B is a scalar, C is a m-by-1 vector, D is a 1-by-n vector. Right now arrayfun would just throw an error.
I wonder if there is something that could first check whether they are compatible, and then apply repmat so that they all become m-by-n. I couldn't find anything, but hopefully someone is better at this.
Edit:
It appears that arrayfun will do this when input is a gpuArray
"B = arrayfun(FUN,A1,...,An) applies FUN to the elements of the arrays A1,...,An, so that B(i,j,...) = FUN(A1(i,j,...),...,An(i,j,...)).The function FUN must take n input arguments and return a scalar. The nonsingleton dimensions of the inputs A1,...,An must all match, or the inputs must be scalar. Any singleton dimensions or scalar inputs are virtually replicated before being input to the function FUN."
I will dig more into this.
1 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!