Execute cellfun on nested cell array

버전 1.0.0.0 (714 Bytes) 작성자: Valerio Biscione
Execute cellfun on nested cell array
다운로드 수: 186
업데이트 날짜: 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 (2026). Execute cellfun on nested cell array (https://kr.mathworks.com/matlabcentral/fileexchange/50133-execute-cellfun-on-nested-cell-array), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2014b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Data Types에 대해 자세히 알아보기
버전 게시됨 릴리스 정보
1.0.0.0