Consolidator bug with custom function handle when no replicates exist

조회 수: 1 (최근 30일)
ZITONG WANG
ZITONG WANG 2020년 5월 5일
답변: Sai Sri Pathuri 2020년 5월 8일
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

답변 (1개)

Sai Sri Pathuri
Sai Sri Pathuri 2020년 5월 8일
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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by