尝试创建classifier_pattern
时出错,如下所示。
classifier_pattern = [25,'no','fine','no';200,'no','hot','yes';100,'no','rainy','no';125,'yes','rainy','no';030,'yes','rainy','no';300,'yes','fine','yes';055,'yes','hot','no';140,'no','hot','no';020,'yes','fine','no';175,'yes','fine','yes';110,'no','hot','yes'];
Matlab错误连接的矩阵的维数不一致。
我不确定为什么会这样。后来我尝试将vertcat
与另一个类似的矩阵一起使用,这也失败了。
答案 0 :(得分:0)
您的问题是您尝试在矩阵中使用字符数组(例如'no'
)。您应该将单元格数组用于混合数据类型。
看一个简单的例子
m = [1, 2, 'no'];
% >> m = ' no' because you have attempted character array concatenation,
% and the 1 and 2 are assumed to be ASCII whitespaces
m = [1, 2, 'no';
3, 4, 'ya;]
% >> m = [' no'; ' ya'] same story, now it's a 2*4 character array
m = [1, 2, 'no';
3, 4, 'yes']
% ERROR: Dimensions not consistent
% This is because you're trying vertical concatenation of 4 and 5 element character arrays.
使用单元格数组修复此问题:
m = {1, 2, 'no';
3, 4, 'yes'};
% >> m = 2*3 cell, as expected.