I have this error : Reference to non-existent field 'mat'.
조회 수: 2 (최근 30일)
이전 댓글 표시
here is the code, I wanted to split the database into training and testing subsets. the error appears ince I run this : observation=dB.mat(k,:); in the code below
function [TrainDBN , TestDBN]=genererDB(dB,Pourcentage_Test)
mapping=getmapping(8,'u2');
V=[];
database=[];
% number of features
dB.classes=[];
classes=[];
dB.Nbofclasses=50;%number of classes
Pourcentage_Test= 0.3;
Pourcentage_Training= 70/100;
for i=1:50
for j=1:15
name=['S' num2str(i,'%02d') '_' num2str(j,'%02d') '.jpg'];
img=imread(name);
imgHist =lbp(img,1,8,mapping,'nh');
database=[database;imgHist];
imshow(img);
dB.NbImagesPerClass(i)=15;
classes=[classes;i];
dB.mat=database;
dB.classes=classes;
pause
end
J=randperm(dB.NbImagesPerClass);
for L=1:length(J)
if J(L)<=Pourcentage_Test*dB.NbImagesPerClass/100;
J(L)=0;
else
J(L)=1;
end
V=[V J];
end
V=V';
TrainDBN.mat=[];
TestDBN.mat=[];
TrainDBN.classes=[];
TestDBN.classes=[];
% Générer les bases d'apprentissage TrainDBN et de test TestDB
for k=1:length(V)
observation=dB.mat(k,:);
if(V(k)==1)
TrainDBN.mat=[TrainDBN.Mat; observation];
TrainDBN.classes=[TrainDBN.classes;dB.classes(k)];
else
TestDBN.mat=[TestDBN.mat; observation];
TestDBN.classes=[TestDBN.classes;dB.classes(k)];
end
end
TrainDBN.NbClasses=dB.Nbclasses;
TestDBN.NbClasses=dB.Nbclasses;
end
[EDITED, Jan, please use a proper code formatting - thanks]
댓글 수: 0
채택된 답변
Jan
2015년 3월 15일
The variable dB.mat is created in the loop. It is strange, that it is missing later on. Therefore I suggest to use the debugger to find out, what's going on. E.g. type this in the command line:
dbstop if error
Then run the code again. When it stops at the error, inspect the contents of the variable dB.
Perhaps you did not save the code after you've edited it?
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Testing Frameworks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!