Error using horzcat dimensions

This is my code
pra= kependudukan((kependudukan(:,6)==1),:);
ks1=kependudukan((kependudukan(:,6)==2),:);
ks2=kependudukan((kependudukan(:,6)==3),:);
Characteristics = {'usia','pendidikan','pekerjaan','Tanggungan','status','luas'};
pairs = [1 2; 1 3; 1 4; 2 3; 2 4; 3 4; 1 5; 1 6; 2 5; 2 6; 3 5; 3 6; 4 5; 4 6;5 6; 6 4];
h = figure;
for j = 1:16,
x = pairs(j, 1);
y = pairs(j, 2);
subplot(4,4,j);
plot([pra(:,x) ks1(:,x) ks2(:,x)],...
[pra(:,y) ks1(:,y) ks2(:,y)], '.');
xlabel(Characteristics{x},'FontSize',10);
ylabel(Characteristics{y},'FontSize',10);
the error: Error using horzcat Dimensions of matrices being concatenated are not consistent.

回答 (1 件)

Rik
Rik 2018 年 5 月 27 日

0 投票

You are try to concatenate (i.e. combine) some arrays that don't have matching sizes. The code below should work, but might not be what you mean.
plot([pra(:,x);ks1(:,x);ks2(:,x)],...
[pra(:,y);ks1(:,y);ks2(:,y)], '.');

カテゴリ

ヘルプ センター および File ExchangeFuzzy Logic Toolbox についてさらに検索

質問済み:

2018 年 5 月 27 日

回答済み:

Rik
2018 年 5 月 27 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by