[英]Error using vertical: Dimensions of matrices being concatenated are not consistent
I am working on a multilayer perceptron classifier (on fisher iris data set, so multiclass classification) and I am getting the above mentioned(on the title of this question) error. 我正在研究多层感知器分类器(在费舍尔虹膜数据集上,所以是多类分类),并且遇到了上面提到的(在这个问题的标题上)错误。 I do not know why, since my matrices have same rows and columns. 我不知道为什么,因为我的矩阵具有相同的行和列。 Everything seems to be correct, but obviously something's not! 一切似乎都是正确的,但显然有些不正确!
CODE: 码:
% Perceptron(Multilayer perceptron)
% coding (+1/-1) of 3 classes
a = [-1 -1 +1]';%'//
b = [-1 +1 -1]';%'//
c = [+1 -1 -1]';%'//
% define training inputs
rand_ind = randperm(50);
trainSeto = meas(rand_ind(1:35),:);
trainVers = meas(50 + rand_ind(1:35),:);
trainVirg = meas(100 + rand_ind(1:35),:);
trainInp = [trainSeto trainVers trainVirg];
% define targets
T = [repmat(a,1,length(trainSeto)) repmat(b,1,length(trainVers))
repmat(c,1,length(trainVirg))];
So, what is wrong with my code and how could I fix it? 那么,我的代码有什么问题,我该如何解决?
Could anyone help me? 有人可以帮我吗?
meas=rand(200,4);
a = [-1 -1 +1]';%'//
b = [-1 +1 -1]';%'//
c = [+1 -1 -1]';%'//
% define training inputs
rand_ind = randperm(50);
trainSeto = meas(rand_ind(1:35),:);
trainVers = meas(50 + rand_ind(1:35),:);
trainVirg = meas(100 + rand_ind(1:35),:);
trainInp = [trainSeto trainVers trainVirg];
% define targets
tmp1 = repmat(a,1,length(trainSeto));
tmp2 = repmat(b,1,length(trainVers));
tmp3 = repmat(c,1,length(trainVirg));
T = [tmp1 tmp2 tmp3];
clear tmp1 tmp2 tmp3 %// Used for cleaning the temporaries
I think MATLAB has difficulties processing the three repmat
calls within the concatenation operator ( []
). 我认为MATLAB难以处理串联运算符( []
)中的三个repmat
调用。 ie I think it tries to repmat
the first, but gets stuck on how and when to repmat
the second. 即,我认为它尝试重新repmat
第一个,但是卡在如何以及何时重新repmat
第二个上。 If you define temporary variables it works fine. 如果定义临时变量,则可以正常工作。 You can use a clear
call if you do not want the temporaries to clutter your workspace. 如果您不希望临时人员使工作空间混乱,则可以使用clear
呼叫。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.