如何摆脱超过矩阵维度(分箱数据)?

时间:2017-06-08 18:57:32

标签: matlab binning

bet{j,3} = react{j};
numBins = {};
edges = linspace(min(bet{j,3}), max(bet{j,3}), numBins(bet{j,3}));
[N, whichBin] = histc(bet{j,3}, edges);
binsize = NaN*zeros(size(bins));

for k = 1:numBins
       bin = find(whichBin == k); 
       binMembers = bet{j,3}(bin);
    if (~isempty(bin))
       mu(k) = mean(y(bin));
    end 
end

错误 edges = linspace(min(bet{j,3}), max(bet{j,3}), numBins(bet{j,3})); that says it exceeds matrix dimensions  对于什么可能是问题的任何建议,以及这些代码的建议是否可以用于分箱数据(例如,反应时间)?

1 个答案:

答案 0 :(得分:0)

您的行numBins = {};会创建一个空单元格数组。但是在numBins(bet{j,3}));中,您正在尝试访问元素。由于没有,它在index exceeds matrix dimension上失败。