필터 지우기
필터 지우기

Dimensions of matrices being concatenated are not consistent.

조회 수: 97 (최근 30일)
Fareeha Yaseen
Fareeha Yaseen 2017년 12월 4일
댓글: THONTI BEERAIAH 2022년 5월 13일
letters=['a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; 'n'; 'o' ;'p'; 'q'; 'r'; 's'; 't' ; 'u' ;'v' ;'w'; 'x' ;'y'; 'z'; 'aa'; 'bb'; 'cc'; 'dd'; 'ee'; 'ff'; 'gg'; 'hh'; 'ii'; 'jj'; 'kk'; 'll'; 'mm'; 'nn'; 'oo'; 'pp'; 'qq'; 'rr'; 'ss'; 'tt'; 'uu'; 'vv'; 'ww'; 'xx'; 'yy'; 'zz'; 'num0'; 'num1'; 'num2'; 'num3'; 'num4'; 'num5'; 'num6'; 'num7'; 'num8'; 'num9'];
increment =1;
for y = 1: 62
for k = 1 : 10
test = strcat(letters(y,:) , num2str(k));
addpath 'C:\Users\Lenovo\Downloads\Documents\Mathworks Matlab 2016a (9.0.0.341360) x64(1)\Matlab-2016a-Win64-Crack\R2016a\bin\FeatureExtraction'
imageName = imread(['training_set',test,'.png']);
imageName = rgb2gray(imageName);
x(:, increment) = (feature_extract(~im2bw(imageName)));
increment = increment + 1;
end;
end;
x = x';
I want to store this in a matrix, i keep getting the error dimensions are not consistent. Please help

채택된 답변

KL
KL 2017년 12월 4일
The error comes from your very first line when you're trying to create a char array called letter. Look at this example,
>> letters = ['a';'b';'c']
letters =
3×1 char array
'a'
'b'
'c'
now just add one more character to the last element,
>> letters = ['a';'b';'cc']
Dimensions of matrices being concatenated are not consistent.
do you see what's the problem? it's simply similar to numeric matrices. You cannot have one element more in just one row. In other words, the width of all the rows must be equal.
One alternative to this would be to declare that variable as a cell array,
>> letters = {'a';'b';'cc'}
letters =
3×1 cell array
'a'
'b'
'cc'
read about them by typing doc cell

추가 답변 (1개)

Mudassir shakeel
Mudassir shakeel 2022년 3월 19일
This error occured only when the dimensions of matrices are not same, like the entiites in each column must be same size

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by