I know how to add a matrix below another matrix.
e.g A = [A; B];
I have two matrixes of different dimensions(both different number of columns and rows) and i need to add them up together. One matrix is the main one and the other one is being added to it. Both of them are in a for loop and so the dimension of the first matrix is keep changing.
e.g for i = 1 :3
AngerHist = [AngerHist;Hist];
end
When I run it is giving me this error :
??? Error using ==> vertcat CAT arguments dimensions are not consistent. –
How do i do it? Any suggestions?
AngerHist = {}; DisgustHist = {};FearHist = {}; HappyHist = {}; SadHist = {};SurpriseHist = {};
Images = 'C:\Users\HP\Documents\MATLAB\Images';
List = dir(Images);
n= size(List,1);
for i = 3:n
List1 = dir(fullfile(Images,List(i).name));
m= size(List1,1);
BASE_DIR = fullfile(Images,List(i).name);
for j = 3: m
I=List1(j).name;
I1= imread(fullfile(BASE_DIR,I),'jpg');
Name = List(i).name;
switch (Name)
case 'Anger'
Hist = UniformLBP(I1);
AngerHist = {AngerHist;Hist};
break;
case 'Disgust'
Hist = UniformLBP(I1);
DisgustHist = {DisgustHist;Hist};
break;
case 'Fear'
Hist = UniformLBP(I1);
FearHist = {FearHist;Hist};
break;
case 'Happy'
Hist = UniformLBP(I1);
HappyHist = {HappyHist;Hist};
break;
case 'Sad'
Hist = UniformLBP(I1);
SadHist = {SadHist;Hist};
break;
case 'Surprise'
Hist = UniformLBP(I1);
SurpriseHist = {SurpriseHist;Hist};
break;
end
end
end
I think that you need to use cells:
The result is: