HI ALL, i need to help me when i run this code of pca i find this error please help me its urgent Thanks.
this is my error:
Undefined variable data.
Error in new_pca (line 35)
Training ( size ( Training ,1) +1 ,:)= data( counter ,:) ;
clcclear all% The total number of samples in each class is denoted by NSamples
NSamples =3; % The number of classes
NClasses =30;counter =1;% Read the data
S=[];% S will store all the images
figure(1);for i=1:NClassesstr = strcat('D:\eigenfaces\s\', int2str(i));str = strcat(str, '.jpg');eval('I=imread(str);');I = rgb2gray(I);I = imresize(I, [50,50]);[m n]=size(I);subplot(ceil(sqrt(NClasses)),ceil(sqrt(NClasses)),i)%imshow(I)
if j==NSamplestitle('TrainingDatasets','fontsize',18) % Each image is represented by one column
data( counter ,:)=I (:) ; % Y is the class label matrix
Y( counter ,1)=NClasses; counter = counter +1;enddrawnow;endNTrainingSamples =2;counter =1;Training =[]; Testing =[]; TrLabels =[]; TestLabels =[];for i=1: NClasses for j=1: NTrainingSamples Training ( size ( Training ,1) +1 ,:)= data( counter ,:) ; TrLabels ( size ( TrLabels ,1) +1 ,1)= Y( counter ,1) ; counter = counter +1; end for j= NTrainingSamples +1: NSamples Testing ( size ( Testing ,1) +1 ,:)= data( counter ,:); TestLabels ( size ( TestLabels ,1) +1 ,:)= Y( counter ,1); counter = counter +1; endendclear data Y I;tic
Best Answer