Use a function that returns multiple values as input argument to another function
显示 更早的评论
Hi,
I have a function CutOffForPctile as given below wherein the input argument "InData" is a column in a dataset/table and Pctile is a scalar value between 0 and 100. This i used to calculate the mean and standard deviation of data points till a specific percentile
function [CutOffMean, CutOffStd] = CutOffForPctile(InData, Pctile)
CutOff = prctile(InData,Pctile);
CutOffMean = mean(InData(InData<=CutOff));
CutOffStd = std(InData(InData<=CutOff));
end
I use the output of the above function as input in grpstats function like below. In the below C is a dataset and Im trying to find mean and std of data points till the 75th percentile within the defined group.
Cstats_Mod = grpstats(C,{'OptDesPt1', 'OptDesPt2'}...
,{'min','mean','max', @(C)CutOffForPctile(C,75),},'DataVars','DEffBasedOnMtlbFun');
My issue is that in the Cstats_Mod I have only one set of values (mean) from the function CutOffForPctile and it doesnt have standard deviation in the output.How can I make it return both
How can I return both mean and std as input argument to grpstats. Note, I dont want to make two seperate functions as I have a fairly big data set and finding the percentile cutoff is a costly process so would like to use it in one go for finding the mean and sd.
Any ideas?
Thanks Hari
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!