フィルターのクリア

Dimensions of matrices being concatenated are not consistent.

100 ビュー (過去 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 Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by