Execute cellfun on nested cell array

バージョン 1.0.0.0 (714 Bytes) 作成者: Valerio Biscione
Execute cellfun on nested cell array
ダウンロード: 184
更新 2015/3/21

ライセンスの表示

I often find myself writing function like cellfun(@(cell1) cellfun(@(cell2), fun(cell2), cell1,'un',0), outcell,'un',0). This can be tedious and error prone. So I wrote this generale nested cell fun which allows you to apply a function to a nested cell. For example, mat is a 1x3 cell array. Each cell contains 2 cells, which contains a matrix of X datapoints. We want to calculate the mean of each matrix. We could call a double cellfun as the one before, or my function:
out=ncellfun(@mean, mat).

The number of levels is determined by the function (it stops until it finds a non-cell). You can specify your own value with a third argument=
out=ncellfun(@cell2mat, mat,1)
in this case the function will be applied to a cell. The third argument specify how many cellfun it needs to be used.
The function has not been written for being fast to run, but to be fast to write. It uses eval, so be warned.

引用

Valerio Biscione (2024). Execute cellfun on nested cell array (https://www.mathworks.com/matlabcentral/fileexchange/50133-execute-cellfun-on-nested-cell-array), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2014b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0