inline function returning multiple output variables
5 次查看(过去 30 天)
显示 更早的评论
tdata = table(["US";"US";"US";"UK";"UK";"TW";"TW";"TW";"TW"], [1;1;5;1.20000000000000;3;4;5;1;2],'VariableNames',{'name','Loss'});
tecdf = @(x) ecdf( x, 'Function', 'survivor');
tout = varfun( tecdf, tdata, 'GroupingVariables','name','Input','Loss')
tout only contains the first output from ecdf function. Is there a way to have it returns both output variables?
Thanks,
0 个评论
采纳的回答
Matt J
2023-8-25
编辑:Matt J
2023-8-25
A wrapper is needed.
tdata = table(["US";"US";"US";"UK";"UK";"TW";"TW";"TW";"TW"], [1;1;5;1.20000000000000;3;4;5;1;2],'VariableNames',{'name','Loss'});
tecdf = @(x) ecdfWrapper( x, 'Function', 'survivor');
tout = varfun( tecdf, tdata, 'GroupingVariables','name','Input','Loss')
function out=ecdfWrapper(x,varargin)
[o1,o2]=ecdf( x, varargin{:});
out=[o1,o2];
end
3 个评论
Image Analyst
2023-8-25
Rather than have to have an anonymous function use a wrapper function, why not just make the anonymous function into a regular function? Then there's no need for the anonymous function anymore.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!