File Exchange

image thumbnail


version (1.25 KB) by Hanan Shteingart
cellfunfun is identical to cellfun but takes care for uniformOutput parameter


Updated 11 Jun 2013

View License

cellfunfun is identical to cellfun with one improvement: you don't need to add that annoying (...,'uniformOutput','false') in the end, if it is necessary. In case it is not necessary, the function operates as if 'uniformOutput','true'. You can also explicitly set 'uniformOutput' to the value you wish.

>> a = {'abc','def'};
>> cellfun(@(x)findstr('a',x),a)
Error using cellfun
Non-scalar in Uniform output, at index 2, output 1.
Set 'UniformOutput' to false.
>> cellfunfun(@(x)findstr('a',x),a)

ans =

[1] []

Comments and Ratings (2)

Matt J

I recommend using 'catch ME' rather than just assuming the try...catch...end will throw an error because of an inappropriate 'UniformOutput' selection.


MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags