Is it possible to apply a vector function to each element of an array?

3 ビュー (過去 30 日間)
Mr M.
Mr M. 2017 年 5 月 20 日
回答済み: Walter Roberson 2017 年 5 月 20 日
I mean, the output of my function is a vector, always the same size. So I want to apply this function to each element of an array, and get a higher dimension array or get a bigger array similar to the output of repmat().

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 20 日
temp = arrayfun(@yourFunction, TheArray, 'Uniform', 0);
output = reshape(cat(1,temp{:}),size(temp,1),size(temp,2),[]);
... you were not clear as to whether your vectors are row vectors or column vectors, and you were not clear as what shape of output you wanted.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by