Dimensions of matrices being concatenated are not consistent.
35 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
KL
on 4 Dec 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
More Answers (1)
Mudassir shakeel
on 19 Mar 2022
This error occured only when the dimensions of matrices are not same, like the entiites in each column must be same size
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!