Grpstats function handles with multiple columns
显示 更早的评论
I want to use a function handle in grpstats which takes multiple columns of a dataset as inputs. The two columns are the lower and higher limits of a confidence interval. I wrote a function for a rough estimate of accumulated confidence intervals.
function [ci_new] = ci_estimate(ci_low_array, ci_high_array)
ci_int = sqrt(sum((ci_low_array - ci_high_array).^2));
ci_mean = mean(mean([ci_low_array, ci_high_array], 2));
ci_new_low = ci_mean - ci_int;
ci_new_high = ci_mean + ci_int;
ci_new = [ci_new_low, ci_new_high];
end
I'm calling the function within grpstats as follows:
ds_o = grpstats( ds_o, {'observer' }, @ci_estimate, 'DataVar', { 'ci_low', 'ci_high' } );
Have tried multiple variations of the above code, including creating a new variable 'ci' which is essentially a matrix containing both low and high values, none of which are working. In the documentation of grpstats, it says that it's possible to write a function that takes a matrix as input instead of a column of dataset, but there's no example, and I can't seem to figure out the current syntax..
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Managing Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!