我正在尝试处理数据集,计算小于给定错误率的条目的出现次数,为每个数据集(X)绘制一个条形图和出现(Y)。看来count的输出是存储在cell类型中的,bar无法识别。如何将其存储在数组中,而不是单元格类型中?
DATASET_SIZE = 100;
PRUN_MAX_ERROR = 2;
PRUN_MISSING_DATA = -1.000;
ERROR_RATE = 0.2;
for i=1:DATASET_SIZE
fid = fopen(strcat('log',int2str(i),'.txt'),'r');
C(i) = textscan(fid, '%.3f');
fclose(fid);
end
%% convert cell type to matrix & process data
for i=1:DATASET_SIZE
D = cell2mat(C(i));
% removing unwanted entries
D(D == PRUN_MISSING_DATA) = [];
D(D > PRUN_MAX_ERROR) = [];
% count number of occurence below certain error rate
% E = [E sum(D <= ERROR_RATE)];
E{i} = sum(D <= ERROR_RATE);
end
figure;
bar(E);
但我得到这个错误:
Undefined function 'real' for input arguments
of type 'cell'.
Error in xychk (line 42)
x = real(y); y = imag(y);
Error in bar (line 54)
[msg,x,y] =
xychk(args{1:nargs},'plot');
Error in checkSeqEffects (line 53)
bar(E);