【发布时间】:2016-07-19 11:14:10
【问题描述】:
这个问题是关于使用 matlab 对数据进行分箱的。我有两个数据集。在一个数据集中,我有 x(代表速度)和 y(代表功率)值,我现在在该计算的帮助下,将它们合并并计算平均 std、edge 和 h 值(参见代码),我想识别并传递我的传入数据(在代码中,这是新数据)到它们所属的特定bin(我已经准备好在下面给出的代码中计算出来),。在下面的代码中,newdata 将包含与 bin 匹配的新数据集。请帮助我在哪里出错或修改它我收到以下错误:
Error using >
Matrix dimensions must agree.
Error in Binning_Online (line 23)
newdatabin=find(newdata>binEdges,1,'last'); %this is the bin number where the new data goes in
代码:
x= load speed;
y= load power;
newdata= load new_speed;
topEdge = 20; % upper limit
botEdge = 5; % lower limit
numBins = 40; % define number of bins
[N,edges,bins] = histcounts(y_vector,numBins);
Pow_means = []; speed_means = [];
for n = 1:numBins;
Pow_means(n,1) = mean(x_vector(bins==n,1)); % for each bins mean value calculation.
speed_means(n,1) = mean(y_vector(bins==n,1)); % for each bins mean value calculation.
pow_std(n,1) = std(x_vector(bins==n,1)); % for Standard deviation calculation
binEdges = linspace(botEdge, topEdge, numBins+1);
newdatabin= find(newdata>binedges,1,'last'); %this is the bin number where the new data goes in
h(newdatabin)=h(newdatabin)+1;
end
【问题讨论】:
-
问题是什么?
-
为什么不写错误信息?
-
@giosans 这是我得到的错误:使用错误 > 矩阵尺寸必须一致。 Binning_Online 中的错误(第 23 行)newdatabin=find(newdata>binEdges,1,'last'); %这是新数据进入的bin号
-
@user4759923 如果您无法理解我的问题,我深表歉意。在这个程序中,使用 binning 方法我的目的是识别传入点属于哪个 bin 或如何识别传入数据点属于哪个 bin 组?希望对你有帮助
-
只是表示数组
newdata的大小与binedges的大小不同。