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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by