Consolidator bug with custom function handle when no replicates exist

2 views (last 30 days)
While using the function consolidator (https://www.mathworks.com/matlabcentral/fileexchange/8354-consolidator), I noticed a bug which occurs when there are no replicates in the x-value ("index").
For example, consider the following scenario,
x = [0;1;1];
y = [1;2;3];
[xc,yc] = consolidator(x,y,@(x)log(mean(x)));
The desired output is:
yc = [log(1); log(5/2)]
But the actual output is:
yc = [1; log(5/2)]
So I think because the x-value 0 is not replicated, the function simply ignores the corresponding value in y, not applying the function to it. I'm wondering if there is a simple fix for this. I'm not sure if this is an intended effect for whatever purpose this function was designed to serve.
EDIT: so I've found a related problem that happens when trying to use functions such as @(x) mean(x) * log(mean(x)). This throws an error asking for (.*) to be used, which gives the wrong answer.
MATLAB Version: 9.6.0.1307630 (R2019a) Update 7

Answers (1)

Sai Sri Pathuri
Sai Sri Pathuri on 8 May 2020
Consolidator is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Feel free to contact the author of this submission directly for specific questions about the implementation

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!