Borrar filtros
Borrar filtros

Dimensions of matrices being concatenated are not consistent.

97 visualizaciones (últimos 30 días)
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

Respuesta aceptada

KL
KL el 4 de Dic. de 2017
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

Más respuestas (1)

Mudassir shakeel
Mudassir shakeel el 19 de Mzo. de 2022
This error occured only when the dimensions of matrices are not same, like the entiites in each column must be same size

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by