How to apply a cell array of function handles to a cell array of arguments
1 次查看(过去 30 天)
显示 更早的评论
I have an MxN cell array fha of type conversion function handles (@double, @char, etc) that I'd like to apply element-by-element to an MxN cell array of strings x, but am struggling with the correct syntax. I've tried:
cellfun(@(s,t) s(t), fha, x, 'uni', 0)
which returns error in @(s,t)s(t) -- index exceeds matrix dimensions, and also:
cellfun(@(s,t) (s,t), fha, x, 'uni', 0)
but that's also flagged as incorrect -- possible unbalanced (, {, or [. Anyone got a clue?
0 个评论
回答(1 个)
Thorsten
2016-8-2
Use nested cellfun calls
X = cellfun(@(fha_i) cellfun(fha_i, C, 'Uni', false), fha, 'Uni', false)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!